JSON Java Script Object Notation Copyright © 2013 Curt Hill.
-
Upload
edwina-small -
Category
Documents
-
view
218 -
download
3
Transcript of JSON Java Script Object Notation Copyright © 2013 Curt Hill.
JSONJava Script
Object NotationCopyright © 2013 Curt Hill
What is it?• Language for data interchange
– Derived from JavaScript (ECMA standard)
– Alternative to XML in that respect
• Both easy for people to read and easy for machines to parse
• Consists of sequences and attribute-value pairs
• It is an open standard
Copyright © 2013 Curt Hill
Simple Types• Does not have many• Number
– A floating point type
• String– Enclosed in double quotes– Uses UNICODE characters
• Boolean– May be true or false
• null– Indicates an empty value
Copyright © 2013 Curt Hill
Structured Types• Only two structuring types• Object
– Similar to a group, record, or struct, depending on language
– Unordered, comma separated list of name value pairs enclosed in braces
– The key is separated from the value by a colon
• Array– An ordered, comma separated list of
values enclosed in bracketsCopyright © 2013 Curt Hill
Commentary• White space may be interspersed
for readability without changing meaning
• Hardly any programming language lacks these features– Most have a JSON interface
• Keys are merely strings
Copyright © 2013 Curt Hill
Example• A simple object to contain a name:
{ “first”:”Bill”, “lastname”: “Smith” }• An array of names inside an object:{ “employees” : [{“first”:”Bill”, “last”:“Sam” },{“first”:”John”, “last”:“Doe” },{“first”:”Curt”, “last”:“Hill” }] }
Copyright © 2013 Curt Hill
Example 2• An array of objects that describe a
products:{“products [ { “name”: “Widget”, “price”:24.91}, { “name”: “Gizmo”, “price”:2.28},{ “name”: “Junk”, “price”:6} ] }
Copyright © 2013 Curt Hill
BSON• Binary JSON also exists• This is a binary encoded
serialization of JSON objects• These should be more compact
and faster to parse
Copyright © 2013 Curt Hill