JavaScript Object Notation is simply a transfer format, much like SOAP or XML-RPC. Unlike those two formats, JSON is not XML based. It is JavaScript code that is loosely based on a C-style definitions and formats. Although called JavaScript Object Notation, many server side languages have built parsers to interpret JSON format. Given this and its lightweight nature, it has become a popular alternative to XML when communicating between a web browser and a client. JSON’s home page is at http://www.json.org.
Let’s quickly review JavaScript objects first. To define a class in JavaScript, you simply treat it as if it was a function. To give the class properties, use the keyword this
, followed by a dot, followed by the name of the property. To give the class methods, also use this
, followed by a dot, the name of the function, an equal sign, the keyword function
and then the function definition. For example, this could be a cat object in...