Figure 4
JavaScript Object Notation (JSON)
JSON, short for JavaScript Object Notation, is a lightweight computer data interchange format that is text-based and readable by humans. JSON uses JavaScript to create ‘name : value’ pairs known as associative arrays which it stores in a JavaScript object.
A simple JSON Object:
var fruitstand = { 'fruitA':'apple', 'fruitB':'orange' };
Where ‘fruitstand’ is an object made up of apples and oranges. If you wanted to find out the value of ‘fruitB’ in javascript, you would use:
window.alert(fruitstand.fruitB);
An alert box should display “orange”.
For more information on JSON, view Patrick Hunlock’s article[3].
Because JSON code is text-based, it is compatible with the browser’s JavaScript source which, unlike the HTTP or XML protocols handled by XMLHttpRequest, is not subject to the tighter cross domain security policies and can thus cross domain barriers as a data-string wrapped in JavaScript. The client application uses the HTML > script < tag to make a request to the web service which returns the data formatted in JSON notation.
Since our application needs JSON formatted data but Amazon’s web service natively outputs XML, the web service API uses a XSLT stylesheet to transform the native XML output into text-based JSON output.