A JSON object is a collection of zero or more key-value pairs called object members. The collection is wrapped in a pair of curly brackets. The key and value are separated by a single colon, while object members are separated with a comma character. The key is a string. The value can be any primitive or complex JSON data type. The structure of a JSON object is shown in the following figure:
JSON object data type
The member name within a JSON object does not need to be unique. The following strings show a JSON text representing an object:
{ "Name":"Mila Radivojevic", "Age":12, "Instrument": "Flute" } {} { "Song":"Echoes", "Group":"Pink Floyd", "Album":{ "Name":"Meddle", "Year":1971 } } { "Name":"Tom Waits", "Name":"Leonard Cohen" }
Since the value can be any data type, including an object or an array, you can have many nested layers. This makes JSON a good choice for even complex data. Note that white spaces are allowed between the key and the value.