For example:
{["NewYork",123]}
For json array is decoded as a go array, and go array is need to explicit define a type, I don't know How to deal with it.
For example:
{["NewYork",123]}
For json array is decoded as a go array, and go array is need to explicit define a type, I don't know How to deal with it.
First that json is invalid, objects has to have keys, so it should be something like {"key":["NewYork",123]}
or just ["NewYork",123]
.
And when you're dealing with multiple random types, you just use interface{}
.
const j = `{"NYC": ["NewYork",123]}`
type UntypedJson map[string][]interface{}
func main() {
ut := UntypedJson{}
fmt.Println(json.Unmarshal([]byte(j), &ut))
fmt.Printf("%#v", ut)
}