September 2013
Beginner to intermediate
480 pages
9h 59m
English
The reverse of the previous recipe is to serialize JavaScript objects into JSON string. Similarly the same rules about having browser support for JSON applies but again this is not a problem in most of the browsers. One way would be to manually create the string, but that is just a way to error-prone and messy browsers, so we will try out some of the methods available out there.
In the following example we use only JavaScript, so we can place it inside a simple script tag in an HTML file:
var someJSON = {
"firstname":"John",
"lastname":"Doe",
"email":"john.doe@example.com"
};Read now
Unlock full access