Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"encoding/json"
"fmt"
)
func main() {
b := []byte(`{"key":"value"}`)
var f interface{}
json.Unmarshal(b, &f)
myMap := f.(map[string]interface{})
fmt.Println(myMap["key"])
}
@aldlfkahs
Copy link

aldlfkahs commented Aug 6, 2021

You saved my life

@bharathraj-e
Copy link

bharathraj-e commented Aug 15, 2021

Simple and saving lives

@satyamkb
Copy link

satyamkb commented Sep 28, 2021

Life saver

@brunotrajano-mm
Copy link

brunotrajano-mm commented Dec 21, 2021

Thanks! It helped a lot

@ashmilhussain
Copy link

ashmilhussain commented Feb 10, 2022

how to do this for a nested data

b := []byte({"key":{"key1":"value"}})

@vmpastran
Copy link

vmpastran commented Feb 17, 2022

Merci beaucoup

@sramac2
Copy link

sramac2 commented Feb 17, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment