Last active
May 15, 2024 08:57
-
-
Save nevzatalkan/f5c5ef66e88dd446976401967b6731e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) | |
} |
thanks!
Thank you very much.
can we not do f.(map[string]string)
directly if we know the values are also string?
Thanks!
Thank you so much
THANK YOU!!!
You saved my life
Simple and saving lives
Life saver
Thanks! It helped a lot
how to do this for a nested data
b := []byte({"key":{"key1":"value"}}
)
Merci beaucoup
Thanks
Omg, thanks again !
Thanks mate!! u bro!!
How to do it for net maps, per example:
map[string]map[string]interface{}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man! You saved my day