Skip to content

Instantly share code, notes, and snippets.

@gophertron
Created August 2, 2016 17:52
Show Gist options
  • Save gophertron/f4540eccb0632f0c9aa83243856d1c6f to your computer and use it in GitHub Desktop.
Save gophertron/f4540eccb0632f0c9aa83243856d1c6f to your computer and use it in GitHub Desktop.
Unmarshal json to map
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