jsonsaga 100605143125-phpapp02
TRANSCRIPT
![Page 1: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/1.jpg)
The JSON SagaDouglas Crockford
Yahoo! Inc.
![Page 2: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/2.jpg)
I am a heretic.
You have been warned.
![Page 3: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/3.jpg)
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.
![Page 4: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/4.jpg)
2001
![Page 5: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/5.jpg)
State Software
2002
![Page 6: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/6.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 7: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/7.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 8: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/8.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 9: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/9.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 10: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/10.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 11: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/11.jpg)
The Very First JSON MessageApril 2001
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{to:"session", do:"test", text:"Hello world"}
);</script></head></html>
![Page 12: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/12.jpg)
The unquoted name problem
• ES3 has a wack reserved word policy.• Reserved words must be quoted.• I did not want to put the list of reserved
words in the JSON spec, so...• All keys must be quoted.• It significantly simplified JSON.• This conforms to Python.
![Page 13: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/13.jpg)
Nested HTML
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{"to":"session", "do":"test", "text":"</script>"}
);</script></head></html>
![Page 14: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/14.jpg)
Nested HTML
<html><head><script>document.domain = 'fudco.com';parent.session.receive(
{"to":"session", "do":"test", "text":"<\/script>"}
);</script></head></html>
![Page 15: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/15.jpg)
JSML
JavaScript Message Language
![Page 16: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/16.jpg)
JSON
JavaScript Object Notation
![Page 17: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/17.jpg)
JSON was really useful
• Browser/server communication.• Interserver communication.• Configuration.• JSON database.
![Page 18: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/18.jpg)
Our customers said
• “Never heard of it.”
• “Sorry, our company just committed to XML.”
• “It is not a standard.”
![Page 19: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/19.jpg)
I bought JSON.org
• A one-page web site that described JSON.• Grammar three ways
Simplified BNFRailroad diagramsInformal English
• A Java reference implementation.
• And then I retired.
![Page 20: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/20.jpg)
And that’s all I did.
A message format in a bottle.
![Page 21: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/21.jpg)
Contributors
![Page 22: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/22.jpg)
Languages• ASP• ActionScript• C• C++• C#• ColdFusion• D• Delphi• E• Eiffel• Erlang• Fantom• Go• Haskell• haXe• Java• JavaScript• Lasso• Lisp• LotusScript• Lua• Objective C
• Objective CAML• OpenLaszlo• Perl• PHP• Pike• PL/SQL• pljson• PowerShell• Prolog• Python• Qt• R• REALbasic• Rebol• RPG• Ruby• Scheme• Squeak• Symbian• Tcl• Visual Basic• Visual FoxPro
![Page 23: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/23.jpg)
JSON is the intersection of modern programming languages
• Simple valuesnumberstringboolean
• Sequence of valuesarray, vector, list
• Collection of named valuesobject, record, struct, map, hash, property list
![Page 24: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/24.jpg)
Recursive descentvalue = function () {
// Parse a JSON value. It could be an object, an array,// a string, a number, or a word.
white();switch (ch) {case '{':
return object();case '[':
return array();case '"':
return string();case '-':
return number();default:
return ch >= '0' && ch <= '9' ? number() : word();}
};
![Page 25: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/25.jpg)
State Machinestate = 'go';stack = [];try {
for (;;) {r = tx.exec(source);if (!r) {
break;}if (r[1]) {
action[r[1]][state]();} else if (r[2]) {
value = +r[2];number[state]();
} else {value = debackslashify(r[3]);string[state]();
}source = source.slice(r[0].length);
}}
![Page 26: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/26.jpg)
Evalif (/^[\],:{}\s]*$/.test(text.replace(
/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-
]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the // text into a JavaScript structure. The '{' operator is subject // to a syntactic ambiguity in JavaScript: it can begin a block // or an object literal. We wrap the text in parens to eliminate // the ambiguity.
j = eval('(' + text + ')');
![Page 27: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/27.jpg)
JSON.parse
• Part of ECMAScript, Fifth Edition• Available now in better browsers
everywhere.• Very fast. Very reliable.
![Page 28: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/28.jpg)
Languages
• Arabic • Bulgarian • Chinese • Czech • Dutch • French • German • Greek • Hebrew • Hungarian • Indonesian
• Italian • Japanese • Korean • Persian • Polish • Portuguese • Russian • Slovenian • Spanish • Turkish • Vietnamese
![Page 29: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/29.jpg)
2005
![Page 30: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/30.jpg)
Improvements
• Removed comments.Dangerous practicesUnnecessary complexityAlignment with YAML
• Added e notation to numbers.
![Page 31: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/31.jpg)
No version number.
• JSON will not be changed.• Stability is more important than any
feature we can think of.• Perhaps someday it will be replaced.
![Page 32: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/32.jpg)
RFC 4627
application/json
![Page 33: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/33.jpg)
Minimalism
It can fit on the back of a business card.
![Page 34: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/34.jpg)
The less we need to agree on, the easier it is to interoperate.
![Page 35: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/35.jpg)
Influences
![Page 36: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/36.jpg)
Lisp
S-expressions1958
![Page 37: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/37.jpg)
Rebol
![Page 38: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/38.jpg)
JavaScriptPython
NewtonScript
![Page 39: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/39.jpg)
NeXT
OpenStep Property Lists1993
![Page 40: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/40.jpg)
XML
The High Priced Spread
![Page 41: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/41.jpg)
HTML
Always bet on angle brackets.
![Page 42: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/42.jpg)
Ask not if it is good enough.Ask if it can be popular enough.
![Page 43: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/43.jpg)
Maybe only something this simple could work.
John Seely BrownCTO Forum, San Francisco
April 2002
![Page 44: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/44.jpg)
Maybe only something this complicated could work.
InfoWorld Next-Generation Web Services II: The Applications
Santa ClaraSeptember 2002
![Page 45: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/45.jpg)
XMLsucks.org
Why XML is technologically terrible, but you have to use it
anyway
![Page 46: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/46.jpg)
XML is the standard so shut up.
SHUT UP!
![Page 47: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/47.jpg)
XML Alternatives
• JSON config YAML CanonML HDF SSYN OGDL SDL DL Boulder ONX SMEL Property lists ConfigObj GroovyMarkup ATerms LNML GODDAG JITTs Esis/Pyxie ConciseXML SML TexMecs A specification language Waterken doc UBF Xqueeze Ool atx Grutatxt APT txt2docbook txt2tags AsciiDoc reStructuredText Epytext EtText AFT txt2html Setext Latte Confluence Markdown SmartyPants Textile Atox CDuce MarkupMatrix WikiMl IWML SEXP sfsexp Lambda markup language SXML Better markup tXML SOX SLiP ezex Tanga (NBML) XSLScript & TerseXML Lx NiceXSL PXSL ShoXS XSCS SML MIN MINML ESPX PXML GMarkup ASN BLOB SDXF CTX ASDL WDDX REBOL
• http://www.pault.com/pault/pxml/xmlalternatives.html
![Page 48: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/48.jpg)
Disruption
Threats
![Page 49: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/49.jpg)
It’s not even XML!Who did this travesty?
Let’s find a tree and string them up. Now.
Dave Winer, 2006-12-20
![Page 50: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/50.jpg)
any damn fool could produce a better data format than XML
James Clark, 2007-04-06
![Page 51: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/51.jpg)
Use the right tool for the right job.
When your only tool is a wrench,every problem looks like a nail.
![Page 52: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/52.jpg)
Where did the idea come from that data should be represented
by a document format?
![Page 53: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/53.jpg)
RUNOFF.SK 1Text processing and word processing systemstypically require additional information tobe interspersed among the natural text ofthe document being processed. This addedinformation, called "markup", serves twopurposes:.TB 4.OF 4.SK 11.#Separating the logical elements of thedocument; and.OF 4.SK 12.#Specifying the processing functions to beperformed on those elements..OF 0.SK 1
![Page 54: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/54.jpg)
GML:h1.Chapter 1: Introduction:p.GML supported hierarchical containers, such as:ol:li.Ordered lists (like this one),:li.Unordered lists, and:li.Definition lists:eol.as well as simple structures.:p.Markup minimization (later generalized and formalized in SGML),allowed the end-tags to be omitted for the "h1" and "p" elements.
![Page 55: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/55.jpg)
:eol.
::ol.
</ol>
![Page 56: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/56.jpg)
Brian Reid’s Scribe
@Quote(Any damn fool)
( ) [ ] { } < > " " ' '
@Begin(Quote)Any damn fool
@End(Quote)
1980
![Page 57: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/57.jpg)
Scribe@techreport(PUB, key="Tesler", author="Tesler, Larry", title="PUB: The Document Compiler", year=1972, number="ON-72", month="Sep", institution="Stanford University Artificial Intelligence Project")
@book(Volume3, key="Knuth", author="Knuth, Donald E.", title="Sorting and Searching", publisher="Addison-Wesley",year=1973, volume=3,series="The Art of Computer Programming", address="Reading, Mass.")
![Page 58: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/58.jpg)
License
MIT
![Page 59: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/59.jpg)
The Software shall be used for Good, not Evil.
I'm looking at you,Osama bin Laden.
![Page 60: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/60.jpg)
I give permission to IBM, its customers, partners, and
minions, to use JSLint for evil.
![Page 61: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/61.jpg)
Thanks very much, Douglas!
Staff Attorney, IP LawIBM Corporation
![Page 62: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/62.jpg)
The JSON Logo
![Page 63: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/63.jpg)
The Impossible Torus
![Page 64: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/64.jpg)
Ambihelical Hexnut
![Page 65: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/65.jpg)
![Page 66: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/66.jpg)
![Page 67: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/67.jpg)
![Page 68: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/68.jpg)
![Page 69: Jsonsaga 100605143125-phpapp02](https://reader033.vdocuments.us/reader033/viewer/2022060117/55879711d8b42ade408b45e3/html5/thumbnails/69.jpg)
www.JSON.org