Loading Please Wait...
JSON array literals are surrounded by big braces [].
JSON array literals are surrounded by big braces [].
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.
// This is a JSON string
'["Ford", "BMW", "Fiat"]'
// Inside the JSON string there is a JSON array literal
["Ford", "BMW", "Fiat"]
You can create a JavaScript array from a JSON literal by parsing it.
myJSON = '["Ford", "BMW", "Fiat"]';
myArray = JSON.parse(myJSON);
You access array values by index.
myArray[0];
Objects can contain arrays.
{
"name":"John",
"age":30,
"cars":["Ford", "BMW", "Fiat"]
}
You access array values by index.
myObj.cars[0];
You can access array values by using a for in loop.
for (let i in myObj.cars) {
x += myObj.cars[i];
}
Or you can use a for loop.
for (let i = 0; i < myObj.cars.length; i++) {
x += myObj.cars[i];
}
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved