I am working on some code to parse JSON data from an HTTP response. The code I have looks something like this:
type ResultStruct struct { result []map[string]string } var jsonData ResultStruct err = json.Unmarshal(respBytes, &jsonData)
json in respBytes variable looks like this:
{ "result": [ { "id": "ID 1" }, { "id": "ID 2" } ] }
However, err not equal to zero. When I print it, it says unexpected end of JSON input . What caused this? It seems that JSON is valid. Does this error have anything to do with my custom structure?
Thanks in advance!
json go unmarshalling
Stratus3d
source share