Presentation is loading. Please wait.

Presentation is loading. Please wait.

JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.

Similar presentations


Presentation on theme: "JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language."— Presentation transcript:

1 JSON

2 JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language independent most programming languages can easily read it and instantiate objects or some other data structure Defined in RFC 4627RFC 4627 Started gaining tracking ~2006 and now widely used http://json.org/ has more information http://json.org/

3 JSON example “JSON” stands for “JavaScript Object Notation” Despite the name, JSON is a (mostly) language-independent way of specifying objects as name-value pairs Example: {"skillz": { "web":[ { "name": "html", "years": 5 }, { "name": "css", "years": 3 }] "database":[ { "name": "sql", "years": 7 }] }}

4 JSON syntax, I An object is an unordered set of name/value pairs The pairs are enclosed within braces, { } There is a colon between the name and the value Pairs are separated by commas Example: { "name": "html", "years": 5 } An array is an ordered collection of values The values are enclosed within brackets, [ ] Values are separated by commas Example: [ "html", ”xml", "css" ]

5 JSON syntax, II A value can be: A string, a number, true, false, null, an object, or an array Values can be nested Strings are enclosed in double quotes, and can contain the usual assortment of escaped characters Numbers have the usual C/C++/Java syntax, including exponential (E) notation All numbers are decimal--no octal or hexadecimal Whitespace can be used between any pair of tokens

6 Comparison of JSON and XML Similarities: Both are human readable Both have very simple syntax Both are hierarchical Both are language independent Both can be used by Ajax Differences: Syntax is different JSON is less verbose (less descriptive) JSON includes arrays Names in JSON must not be JavaScript reserved words XML can be validated JavaScript is not typically used on the server side

7 Evaluation JSON is simpler than XML and more compact No closing tags, but if you compress XML and JSON the difference is not so great XML parsing is hard because of its complexity JSON has a better fit for OO systems than XML JSON is not as extensible as XML Preferred for simple data exchange by many Less syntax, no semantics Schemas? We don’t need no stinkin schemas! Transforms? Write your own. Worse is better

8 The End


Download ppt "JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language."

Similar presentations


Ads by Google