40 likes | 50 Views
Consuming Java Script Object Notation (JSON) feeds. What is JSON? . JSON stands for J ava S cript O bject N otation is syntax for storing and exchanging text information Much like XML is smaller than XML, and faster and easier to parse.
E N D
What is JSON? • JSON • stands for JavaScript Object Notation • is syntax for storing and exchanging text information • Much like XML • is smaller than XML, and faster and easier to parse {"employees": [{ "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" }]}
Contrasting XML to JSON • Similarities: • both are • Plain-text • Self-describing (human readable) • Hierarchical (values nested within values) • Differences: • JSON • Uses no end tags • Is shorter • Quicker to read and write • Uses arrays
JSON syntax • JSON data • written as name/value pairs • Separated by commas (,) • JSON objects • Enclosed in curly brackets ({}) • JSON arrays • Delineated by square brackets ([]) "firstName" : "John" { "firstName":"John" , "lastName":"Doe" } {"employees": [{ "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" }]}