Json (Javascript Object Notation) : B.Anirudh 08071A1208
Json (Javascript Object Notation) : B.Anirudh 08071A1208
Json (Javascript Object Notation) : B.Anirudh 08071A1208
B.ANIRUDH 08071A1208
Contents
1. 2. 3. 4. 5. 6. 7. 8. 9. ABSTRACT HISTORY JSON STRUCTURE DATA TYPES XML TO JSON JSON OVER XML JSON SCHEMA JSON IN JAVA SCRIPT CONCLUSION
Abstract
JSON ( JavaScript Object Notation) is a lightweight textbased open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays. The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json. The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML.
History
Douglas Crockford was the first to specify and popularize the JSON format. JSON was used at State Software, a company co-founded by Crockford, starting around 2001. The JSON.org website was launched in 2002. In December 2005, Yahoo! began offering some of its web services in JSON. Google started offering JSON feeds for its web protocol in December 2006.
JSON Structure
JSON is built on two structures 1. A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. e.g.: An object with three properties named "a", "b , and "c" { "a":1,"b":2,"c":3 } 2. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence. e.g.: An array of three integers and one string value [ 1, 2, 3, "value #4 with" ]
Data Types
JSON's basic types are: Number String Boolean (true or false) Array (an ordered sequence of values, commaseparated and enclosed in square brackets; the values do not need to be of the same type) Object (an unordered collection of key :value pairs with the ':' ) null(empty)
XML TO JSON
<?xml version="1.0" encoding="UTF-8" ?> <firstName>John</firstName> <lastName>Smith</lastName> <age>25</age> <address> <streetAddress>21 2nd Street</streetAddress> <city>New York</city> <state>NY</state> <postalCode>10021</postalCode> </address> <phoneNumber> <type>home</type> <number>212 555-1234</number> </phoneNumber> <phoneNumber> <type>fax</type> <number>646 555-4567</number> </phoneNumber> } { "firstName": "John", "lastName" : "Smith", "age" : 25, "address" : { "streetAddress": "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : "10021" }, "phoneNumber": [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ]
Schema
There are several ways to verify the structure and data types inside a JSON object, much like an XML schema; however unlike XML schema, JSON schemas are not widely used. Additionally JSON Schema have to be written manually. JSON Schema is a specification for a JSON-based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how it can be modified, much like the XML Schema provides for XML. JSON Schema is intended to provide validation, documentation, and interaction control of JSON data.
JSON SCHEMA
JSON SCHEMA
{ "name":"Product", "properties": { "id": { "type":"number", "description":"Product identifier", "required":true }, "name": { "type":"string", "description":"Name of the product", "required":true } } }
JSON SCRIPT
{ "id": 1, "name": vnr }
CONCLUSION
Currently, JSON is very young but it has a very bright future. It is the most efficient way of representing data that that is being exchanged over a network connection in terms of ease of use and speed of processing. JSON is also very flexible and can be used with almost any programming language. These factors make JSON a very attractive alternative to XML. JSON is continuously gaining ground and getting more attention in the world of web applications. Today, most web browsers, including Firefox 3.5, Internet Explorer 8, and Safari, all run native JSON.
ANY QUERIES
??
THANK YOU