This question already has an answer here:
I am new to golang and trying to parse some response from a web service, and the response looks like:
[
{
"Data": {
"KeyA": 1,
"KeyB": 2
},
"Type": 0
},
{
"Data": {
"KeyX": "ValueX",
"KeyY": 999
},
"Type": 1
},
{
"Data": {
"Val": 123,
"Id": "999",
"Cnt": 100
},
"Type": 2
}
]
You can see that each element has a Key "Data" and "Type" (Must), but with different 'Type' comes the different 'Data' field.
Could you please suggest a efficiency way to construct this kind of response to Golang structure?
Thanks.
</div>