What is the difference between JSON and Array?

What is the difference between JSON and Array? Why do they call JSON objects and array objects.

http://wiki.appcelerator.org/display/guides/Using+TableViews+-+data.js

Is it an array or JSON? How can I identify?

+4
source share
2 answers

JSON is a data format based on a subset of JavaScript.

A simplified version of the specification is available on the JSON page. Full specification available as RFC IETF.

Libraries exist in different languages ​​for converting from a JSON data string to data structures suitable for that language (and for switching to the other side). A list of some of them can be found at the bottom of the JSON homepage.

An array is a data structure common to most programming languages ​​that contains a number of variables in a specific order. JSON has an array data type.

A JSON object is a serialization of a collection of key / value pairs. Most programming languages ​​have an appropriate data structure, such as a hash in Perl or a (simple) object in JavaScript.

The page you are linking to does not mention JSON. It has a variable ( weatherData ), which is assigned a simple object (using the object literal {} ), which has one key ( reports ), which is assigned an array (using the array literal [] ), which contains several objects, each of which consists of groups of key / value pairs, where the values ​​are all strings.

If you were to remove the first line and the half-line at the end, then an example would be a JSON data structure representing the same information. This is due to the fact that, as I said earlier, JSON is based on a subset of JavaScript and that part of the example corresponds to a subset.

+5
source

This is not JSON text ( JSON is a text data interchange format - if it is not String , it is not JSON) nor a Array .

This is a Object , defined as an object literal , with one property - reports - which is an Array (defined as an array literal ) of Object instances with properties that describe weather conditions in cities.

0
source

All Articles