Created
August 2, 2016 17:52
-
-
Save gophertron/f4540eccb0632f0c9aa83243856d1c6f to your computer and use it in GitHub Desktop.
Unmarshal json to map
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" | |
) | |
type Any interface{} | |
func main() { | |
var jsonBlob = []byte(`{"Prop": {"Pulp": {"Wofoo": 35}}, "Order": "Monotremata"}`) | |
config := make(map[string]Any) | |
err := json.Unmarshal(jsonBlob, &config) | |
if err != nil { | |
fmt.Println("error:", err) | |
} | |
fmt.Printf("%+v", config["Prop"]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment