Is there any difference between '{' and '[' when formatting a JSON object?
' { } ' used for Object and ' [] ' is used for Array in json.
JSONObject and JSONArray are the two common classes usually available in most of the JSON processing libraries. A JSONObject stores unordered key-value pairs, much like a Java Map implementation. A JSONArray, on the other hand, is an ordered sequence of values much like a List or a Vector in Java.
JSON Syntax JSON defines only two data structures: objects and arrays. An object is a set of name-value pairs, and an array is a list of values. JSON defines seven value types: string, number, object, array, true, false, and null.
From json.org "An object is an unordered set of name/value pairs." You should write your JSON processor so that order doesn't matter.
Yep one {...}
is used to define a single object, while the other [...]
is used to define a sequence of either objects, values or lists ...
objects are defined as such {key:object or list or value , ...}
list ares nothing more than a sequence of either objects or lists or values, [objects or list or values, ... ]
...
[{'value':1}, {'values':[1,2,3,3, {'a':'a', 'b':'b'}]}, 2, 3, 4]
'{ }
' used for Object and '[]
' is used for Array in json
Like
var sampleObj = { a:1, b:'ab' }; var sampleArr = [1,'ab',4];
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