Different Between Array And JSON
|
Array |
JSON |
| An array is a special variable, which can hold more than one value at a time. |
JSON format is easy to understanding and for storing and transporting data.JSON is often used when data is sent from a server to a web page.JSON is "self-describing" and easy to understand. |
| An array is a data structure common for all programming languages which contains a number of variables in a specific order. | A JSON Object is a serialisation of a collection of key/value pairs. Most programming languages have a matching data structure, such as a hash in Perl or a (simple) object in JavaScript. |
| Array can create by key and value if you want or default it will have index value as key value | JSON always have key and value |
Example:
$bike = array("Bike1", "Bike2", "Bike3");
|
Example:
{"employees":[
{ "firstName":"John", "lastName":"Doe" },
{ "firstName":"Anna", "lastName":"Smith" },
{ "firstName":"Peter", "lastName":"Jones" }
]}
|