I've had a heck of a time parsing JSON strings and finally landed on https://github.com/bitly/go-simplejson. It looks really promising but it's still giving me an empty result for the following JSON array:
{
"data": {
"translations": [
{
"translatedText": "Googlebot: Deutsch, um die Luft-Speed-Geschwindigkeit einer unbeladenen Schwalbe?"
}
]
}
}
I want to get to translatedText
by only specifying the key. The reason for this is my JSON structure won't be predictable and so I'd like to target any JSON array but specifying a key without knowing the full structure of the JSON array.
This is the snippet of code I use where content
contains the JSON byte array:
f, err := js.NewJson(content)
if err != nil {
log.Println(err)
}
t := f.Get("translatedText").MustString()
log.Println(t)
t
is always blank :( Would appreciate any pointers.