Forked from nevzatalkan/golang convert interface to map
Created
June 13, 2019 15:58
-
-
Save alkanna/c96612db3744990ae68bd0bce5414314 to your computer and use it in GitHub Desktop.
This file contains hidden or 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"]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment