Java Reference
In-Depth Information
12
JSON 
What You Will learn in this Chapter:
Discovering the limitations of using XML with JavaScript
Recognizing the differences between JavaScript and JSON
Serializing objects using the built‐in JSON object
Parsing JSON back into actual objects and values you can use in
your pages
Wrox.Com Code doWnloads for this Chapter
You can find the wrox.com code downloads for this chapter at http://www.wiley.com/go/
BeginningJavaScript5E on the Download Code tab. You can also view all of the examples
and related files at http://beginningjs.com .
If you aren't already, start thinking of a web page as a program. It does, after all, have all
the trappings of a traditional program. It has a user interface, and it can process data with
JavaScript. But as you well know, traditional programs can do more; they can store data as
well as transmit data to other computers and systems. In the coming chapters, you learn that
you can do the same things in a web page—all thanks to JavaScript.
But as you soon learn, you can't just store objects and arrays as they are; instead, you need to
serialize them. Serialization is the process of translating an object into a string representation
of that object. Once an object is serialized, the string representation of that object can then be
stored in a more permanent storage facility or transmitted to another computer.
Serialization translates only the structure and pertinent information of an object—that is,
only the properties are present in a serialized object. But once you need to work with the
object within JavaScript, you can deserialize it, converting it back into a native JavaScript
object.
 
Search WWH ::




Custom Search