There are a few questions on the topic but none of them seem to cover my case, thus I\'m creating a new one.
I have JSON like the following:
{\"foo\"
Assign the values of nested json to struct until you know the underlying type of json keys:-
package main
import (
"encoding/json"
"fmt"
)
// Object
type Object struct {
Foo map[string]map[string]string `json:"foo"`
More string `json:"more"`
}
func main(){
someJSONString := []byte(`{"foo":{ "bar": "1", "baz": "2" }, "more": "text"}`)
var obj Object
err := json.Unmarshal(someJSONString, &obj)
if err != nil{
fmt.Println(err)
}
fmt.Println("jsonObj", obj)
}