JSON: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 2: Line 2:
Load a [[wp:JSON|JSON]] string into a data structure. Also create a new data structure and serialize it into JSON.
Load a [[wp:JSON|JSON]] string into a data structure. Also create a new data structure and serialize it into JSON.
Use objects and arrays, and make sure your JSON is valid (http://www.jsonlint.com/).
Use objects and arrays, and make sure your JSON is valid (http://www.jsonlint.com/).

=={{header|JavaScript}}==
Requires JSON library, now present in some browsers.
<lang JavaScript>
var data = JSON.parse('{ "foo": 1, "bar": [10, "apples"] }')

var sample = { "blue": [1,2], "ocean": "water" };
var json_string = JSON.stringify(sample);

</lang>


=={{header|Python}}==
=={{header|Python}}==