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.
Similar to other programming languages, a JSON Array is a list of items surrounded in square brackets ([]). Each item in the array is separated by a comma.
' { } ' used for Object and ' [] ' is used for Array in json.
Yes, you can create an array of objects. Technically, a 2D array is valid JSON.
The second is almost correct:
{ "foos" : [{ "prop1":"value1", "prop2":"value2" }, { "prop1":"value3", "prop2":"value4" }] }
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