I have a service which provides me properties through REST. Now I want to unmarshal the body into a properties struct. Please see this playground example: click. When I have only one property, I can easily unmarshal it into a Property
. However the ACTUAL response from the server is somehow difference. The actual response I want to unmarshal is this:
[
{
"key": "blabla",
"secret": false,
"type": "string",
"value": "hereisthevalue"
},
{
"key": "yepyepakey",
"secret": true,
"type": "string",
"value": "dummy"
}
]
Unfortunately I don't know how to unmarshal this. Can someone please point me in the right direction?
You need to unmarshal into a slice of Property: http://play.golang.org/p/eRgjfBHypH
var props []Property
er := json.Unmarshal(resp, &props)
if er != nil {
panic(er)
} else {
fmt.Println(props)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With