Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript and JSON array

I am trying to understand how a single and multidimensional javascript array would appear in JSON. Can anyone help me with an example for each?

like image 921
ScG Avatar asked Mar 10 '10 03:03

ScG


People also ask

What is a JSON array?

JSON array are ordered list of values. JSON arrays can be of multiple data types. JSON array can store string , number , boolean , object or other array inside JSON array. In JSON array, values must be separated by comma. Arrays in JSON are almost the same as arrays in JavaScript.

Can JSON parse array?

Use the JSON. parse() method to pase a JSON array, e.g. JSON. parse(arr) . The method parses a JSON string and returns its JavaScript value or object equivalent.

What is difference between JSON and array?

An array is a data structure common to most programming languages which contains a number of variables in a specific order. JSON has an array data type. A JSON Object is a serialisation of a collection of key/value pairs.


1 Answers

Single-dimensional:

["one", "two", "three"]

Multi-dimensional:

[["one", "two", "three"],
 ["four", "five", "six"]]
like image 197
Justin Ethier Avatar answered Oct 14 '22 07:10

Justin Ethier