Our site is ads supported. Please disable your ad blocker and reload the page. Thank you!

Arrays in JSON

1 1 1 1 1 Arrays in JSON5.00Rating 5.00 (921 Votes)

Example

[ "Ford", "BMW", "Fiat" ]


Arrays in JSON are almost the same as arrays in JavaScript.

In JSON, array values must be of type string, number, object, array, boolean or null.

In JavaScript, array values can be all of the above, plus any other valid JavaScript expression, including functions, dates, and undefined.

Arrays can be values of an object property:

Example
{
"name":"John",
"age":30,
"cars":[ "Ford", "BMW", "Fiat" ]
}

The objects returned from most Server APIs are highly nested:

{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Dog's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}

SourceŃ‹: https://www.w3schools.com/js/js_json_arrays.asp  https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html

You have no rights to post comments

Sunday the 23rd.