Issue
I would like to know, whats the right structure for a list of objects in JSON.
We are using JAXB to convert the POJO's to JSON.
Here is the choices, Please direct me what is right.
foos: [
foo:{..},
foo:{..}
]
or
foos : [
{...},
{...}
]
If the first structure is right, what is the JAXB annotation I should use to get the structure right.
Solution
The first example from your question,
foos: [ foo: { ... }, foo: { ... } ]
is in invalid syntax. You cannot have object properties inside a plain array.
The second example from your question,
foos: [ { ... }, { ... } ]
is right although it is not strict JSON. It's a relaxed form of JSON wherein quotes in string keys are omitted.
Following is the correct one when you want to obey strict JSON:
"foos": [
{ ... },
{ ... }
]
This tutorial by Patrick Hunlock, may help to learn about JSON and this site may help to validate JSON.
Answered By - BalusC
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.