Nested JSON

189 views
Skip to first unread message

Steven Rice

unread,
Feb 14, 2014, 11:26:38 AM2/14/14
to golan...@googlegroups.com
Okay, I was attempting to develop a tool to parse JSON information. The problem I ran into was that there are many nested objects in this. 
The objects look somethig like this {metadata: foo; cases: {caseNumber: 12345678; symptom: blah; customer: {name: John Doe; phone: 5555555555}}; numcases: x}
I was wondering how I could get this to unmarshal correctly. Do I need to create a struct for every nested object or is there a way I can dump a section to an array or hash map?
Also, I do have the number of cases available in the metadata for me if I need to know that to parse but if there was a good way to push it through to objects without knowing that would be easier than parsing twice.
Message has been deleted

Matt Reiferson

unread,
Feb 14, 2014, 2:37:48 PM2/14/14
to Islan Dberry, golang-nuts


On Fri, Feb 14, 2014 at 12:09 PM, Islan Dberry <island...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matthew Holt

unread,
Feb 14, 2014, 7:36:08 PM2/14/14
to golan...@googlegroups.com
This tool will convert JSON to a Go type definition for you... it's a good learning tool too: http://mholt.github.io/json-to-go/

Steven Rice

unread,
Feb 15, 2014, 3:35:48 AM2/15/14
to golan...@googlegroups.com
Thank you guys
Reply all
Reply to author
Forward
0 new messages