Java Reference
In-Depth Information
var wonderWoman = {
name: "Wonder Woman",
"real name": "Diana Prince",
height: 72,
weight: 165,
hero: true,
villain: false,
allies: ["Wonder Girl","Donna Troy","Superman"],
lasso: function(){
console.log("You will tell the truth!");
<< "{\"name\":\"Wonder Woman\",\"real name\":\"Diana
"allies\":[\"Wonder Girl\",\"Donna Troy\",\"Superman\"]}"
Note that the quote marks are escaped and any methods an object has (such as the afore-
mentioned lasso method) will simply be ignored by the stringify method.
These methods are useful when passing data to and from a web server using Ajax requests
(see Chapter 13 ) or when using localStorage to store data on a user's machine (see Chapter
14 ) . JSON data is easy to exchange between different services as most languages and pro-
tocols are able to interpret data as strings of text.
Search WWH ::

Custom Search