Generally an array can be defined as a collection of similar elements, in a JSON array represents a list of values in ordering way and it will store the multiple values also. JSON array has the ability to store the string, boolean, number. JSON array will be represented as
[]
. Following are the examples for JSON array.
Following is an example to represent the array of strings and each string is separated by a comma.
[html]
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
[/html]
Following is an example to represent the array of numbers and each number is separated by a comma.
[html]
[12, 34, 56, 43, 95]
[/html]
Following is an example to represent the array of booleans and each boolean is separated by a comma.
[html]
[true, true, false, false, true]
[/html]
Following is an example to represent the array of objects and each object is separated by a comma.
[html]
{
"students":
[
{"name":"Sachin", "email":"sachin@gmail.com", "age":23},
{"name":"samules", "email":"samules@gmail.com", "age":28},
{"name":"John", "email":"john@gmail.com", "age":33},
{"name":"Bob", "email":"bob32@gmail.com", "age":41}
]
}
[/html]
[html]
[
[ "s", "a", "i" ],
[ "a", "n", "t" ],
[ "i", "t", "s" ]
]
[/html]