Notes 20 - json

Notes 20 - json - JSON JavaScript Object Notation Some of...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
2008-2010 Copyright E. Horowitz, M. Papa 1 JSON – JavaScript Object Notation Some of the slides taken from Douglas Crockford / Yahoo! Inc.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008-2010 Copyright E. Horowitz, M. Papa 2 What is JSON JSON , short for JavaScript Object Notation , is a lightweight data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays (called objects). The JSON format is specified in RFC 4627 by Douglas Crockford. The official MIME type for JSON is application/json. The JSON file extension is .json. The JSON format is often used for transmitting structured data over a network connection in a process called serialization. Its main application is in Ajax web application programming, where it serves as an alternative to the use of the XML format. Code for parsing and generating JSON data is readily available for a large variety of programming languages. The www.json.org website provides a comprehensive listing of existing JSON bindings, organized by language.
Background image of page 2
2008-2010 Copyright E. Horowitz, M. Papa 3 Brief History JSON was based on a subset of the JavaScript programming language (specifically, Standard ECMA-262 3rd Edition—December 1999) however it is considered to be a language-independent data format. E.g. see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf The JavaScript ECMA standard is based upon Netscape’s JavaScript and Microsoft’s JScript Douglas Crockford was the original developer of JSON while he was at State Software, Inc. He is now at Yahoo! http://www.json.org/ , is a website devoted to JSON discussions and includes many JSON parsers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008-2010 Copyright E. Horowitz, M. Papa 4 How to use the JSON format A JSON file allows one to load data from the server or to send data to it. Working with JSON involves three steps: (i) the browser processing, (ii) the server processing, and (iii) the data exchange between them. 1. Client side (browser) The content of a JSON file, or the definition of JSON data is assigned to a variable, and this variable becomes an object of the program. 2. Server side a JSON file on the server can be operated upon by various programming languages, including PHP and Java thanks to parsers that process the file and may even convert it into classes and attributes of the language. 3. Data exchange Loading a JSON file from the server may be accomplished in JavaScript in several ways: - directly including the file into the HTML page, as a JavaScript .js external file. - loading by a JavaScript command - using XMLHttpRequest To convert JSON into an object, it can be passed to the JavaScript eval() function.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2011 for the course CSCI 571 taught by Professor Papa during the Fall '07 term at USC.

Page1 / 33

Notes 20 - json - JSON JavaScript Object Notation Some of...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online