Consuming Java Script Object Notation (JSON) feeds
JSON, short for JavaScript Object Notation, is a lightweight syntax for data exchange. Compared to XML, JSON is simpler, faster, and easier to read. Learn about its syntax, structure, and differences from XML here.
Consuming Java Script Object Notation (JSON) feeds
E N D
Presentation Transcript
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" }]}