go - Golang - Parsing nested JSON -


i'm using go-worker process resque jobs. job has payload has nested json structure this:

[{   "key-a":"val-a",   "key-b":"val-b",   "files":[{     "key-a": [       {"a":"b","c": "d"},       {"e":"f","g": "h"}     ],     "key-b": [       {"a":"b","c": "d"},       {"e":"f","g": "h"}     ]   }] }] 

now go-worker gives me args ...interface{} represents json payload, not actual json text. there idiomatic way convert that(args) correct types (could use package this.) using type assertions manually seems bit tedious such thing.

if it's giving actual go objects (i.e. bunch of map[string]interface{} , not json string itself) there isn't can besides bunch of type assertions.

you re-marshall json parse again correct structs, that's bit of hack (and have no idea if performant or not).


Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -