[ad_1]
There are several issues in your code.
First of all, all the fields of your
editstruct must be exported which means you should capitalize the first letter of every fields.
Just like the following:type edit struct { Id Values }The data type of of
keyof theValuesfield must be string to be able to decode thejsondata.type edit struct { Id int Values map[string]interface{} }Finally, data type of your
jsondata"id"is wrong. It must beintto be matched to yourGostruct. Also, there is no"m"defined in your struct. The"m"must be replaced with"values"to match yourGostruct. Just like the following{ "id": 5, "values":{ "name": "alice" } }
Just to let you know, you can simply use following piece of code to unmarshal json data into Go struct.
err := json.Unmarshal([]byte(a), &s)
1
[ad_2]
solved How to decode embedded json? [closed]