The JSON Saga JSON The worlds best loved
The JSON Saga
JSON • • • The world’s best loved data interchange format. A Subset of ECMA-262 Third Edition. Language Independent. Text-based. Light-weight. Efficient.
I Discovered JSON • I do not claim to have invented JSON. It already existed in nature. • I do not claim to have been the first to discover it. • I gave it a specification and a little website. • The rest happened by itself.
Influences • LISP S-expressions • Rebol • Java. Script • Python • Newton. Script
April 2001 The shed behind Chip Morningstar’s house
2001
The Very First JSON Message <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
Delivered to a hidden frame <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
Circumvent the same origin policy <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
Pass the message to the session object <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
The very first JSON message <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
Syntax error <html><head><script> document. domain = "fudco. com"; parent. session. receive({ to: "session", do: "test", text: "Hello world" }); </script></head></html>
ECMAScript Third Edition Reserved Words abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends false finally float for function goto if implements import in instanceof interface long native new null package private protected public return short static super switch synchronized this throws transient true try typeof var void volatile while with
JSML Java. Script Message Language
JSON Java. Script Object Notation
JSON was really useful • • Browser/server communication. Interserver communication. Configuration. JSON database.
Our customers said • “Never heard of it. ” • “Sorry, our company just committed to XML. ” • “It is not a standard. ”
I became a standards body. json. org
Design Principles • Minimal • Textual • Subset of Java. Script • Free and unencumbered
ECMAScript Third Edition Reserved Words abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends false finally float for function goto if implements import in instanceof interface long native new null package private protected public return short static super switch synchronized this throws transient true try typeof var void volatile while with
Quoted property names
json. org • Informal English • Railroad Diagrams • Mc. Keeman Form Grammar
Translations ﺍﻟﻌﺮﺑﻴﺔ Български 中文 Český Dansk Nederlands English Esperanto Français Deutsch Ελληνικά עברית Magyar Indonesia Italiano 日本 한국어 ﻓﺎﺭﺳی Polski Português Română Русский Српско-хрватски Slovenščina Español Svenska Türkçe Tiếng Việt
YAML Single quote strings Comments
RFC 4627: MIME Media Type application/json
JSON v XML
How JSON Works Graph Theory Syntax
Graph Theory Mathematics • Vertices • Edges • Non-Directional Computer Science • Nodes • Links, arcs • Uni-Directional
Graphs and Trees Graphs • All nodes can have zero or more in-coming links. Trees • All non-root nodes have exactly one in-coming link. • All nodes can have zero or more out-going links. • JSON does not like graphs. • JSON likes trees.
Syntax JSON is a grammar for expressing trees as text, and nothing more.
Values • • Strings Numbers Objects Arrays true false null
Values
String
Number
Object
Array
Why JSON Works The Intersection of all Programming Languages
JSON Looks Like Data • JSON’s simple values are the same as used in programming languages. • No restructuring is required: JSON’s structures look like conventional programming language structures. • JSON’s object is record, struct, object, dictionary, hash, associate array. . . • JSON’s array is array, vector, sequence, list. . .
It is the responsibility of every application to validate its inputs. This cannot be delegated. Being well-formed and valid is not the same as being correct and relevant.
Versionless • JSON has no version number. • There is no non-breaking mechanism for revising the JSON grammar. • JSON is very stable.
Minimalism The less we need to agree on, the easier it is to interoperate.
Bad Practices
Attribute/element confusion { "@attribute": "confusion" }
[ { "name": "height", "value": 188 { }, { "height": 188, "weight": 78 "name": "weight", "value": 78 } ] }
www. JSON. org
The Impossible Torus
Ambihelical Hexnut
The Impossible Torus
Alfred Hitchcock’s Vertigo
Advice to data format standard designers • Don’t break JSON. • Make it significantly better. • Get a better name.
JSON Java. Script Object Notation
- Slides: 58