The  JSON  Saga Douglas Crockford Yahoo! Inc.
I am a heretic. You have been warned.
I Discovered JSON <ul><li>I do not claim to have invented JSON.  It already existed in nature.  </li></ul><ul><li>I do not...
2001
State Software 2002
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li>...
The unquoted name problem <ul><li>ES3 has a wack reserved word policy. </li></ul><ul><li>Reserved words must be quoted. </...
Nested HTML <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session...
Nested HTML <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session...
JSML JavaScript Message Language
JSON JavaScript Object Notation
JSON was really useful <ul><li>Browser/server communication. </li></ul><ul><li>Interserver communication. </li></ul><ul><l...
Our customers said <ul><li>“Never heard of it.” </li></ul><ul><li>“Sorry, our company just committed to XML.” </li></ul><u...
I bought JSON.org <ul><li>A one-page web site that described JSON. </li></ul><ul><li>Grammar three ways </li></ul><ul><ul>...
And that’s all I did. A message format in a bottle.
Contributors
Languages <ul><li>ActionScript </li></ul><ul><li>C </li></ul><ul><li>C++ </li></ul><ul><li>C# </li></ul><ul><li>ColdFusion...
JSON is the intersection of modern programming languages <ul><li>Simple values </li></ul><ul><ul><li>number </li></ul></ul...
Recursive descent <ul><li>value = function () { </li></ul><ul><li>// Parse a JSON value. It could be an object, an array, ...
State Machine <ul><li>state = 'go'; </li></ul><ul><li>stack = []; </li></ul><ul><li>try { </li></ul><ul><li>for (;;) { </l...
Eval <ul><li>if ( /^[],:{}s]*$/ .test(text.replace( </li></ul><ul><li>/?:[&quot;bfnrt]|u[0-9a-fA-F]{4})/g , '@').replace( ...
JSON.parse <ul><li>Part of ECMAScript, Fifth Edition </li></ul><ul><li>Available now in better browsers everywhere. </li><...
Languages <ul><li>Arabic  </li></ul><ul><li>Bulgarian  </li></ul><ul><li>Chinese  </li></ul><ul><li>Czech  </li></ul><ul><...
Ajax! 2005
Improvements <ul><li>Removed comments. </li></ul><ul><ul><li>Dangerous practices </li></ul></ul><ul><ul><li>Unnecessary co...
No version number. <ul><li>JSON will not be changed. </li></ul><ul><li>Stability is more important than any feature we can...
Minimalism It can fit on the back of a business card.
Influences
Lisp S-expressions 1958
Rebol
JavaScript Python NewtonScript
NeXT OpenStep Property Lists 1993
XML The High Priced Spread
HTML Always bet on angle brackets.
Ask not if it is good enough. Ask if it can be popular enough.
Maybe only something  this simple could work. John Seely Brown CTO Forum, San Francisco April 2002
Maybe only something this complicated could work. InfoWorld Next-Generation Web Services II: The Applications Santa Clara ...
XMLsucks.org Why XML is technologically terrible, but you have to use it anyway
XML is the standard so shut up. SHUT UP!
XML Alternatives <ul><li>JSON config YAML CanonML HDF SSYN OGDL SDL DL Boulder ONX SMEL Property lists ConfigObj GroovyMar...
Disruption Threats
It’s not even XML! Who did this travesty?  Let’s find a tree and string them up. Now.  Dave Winer, 2006-12-20
any damn fool could produce a better data format than XML James Clark, 2007-04-06
Use the right tool  for the right job. When your only tool is a wrench, every problem looks like a nail.
Where did the idea come from that data should be represented by a document format?
RUNOFF <ul><li>.SK 1 </li></ul><ul><li>Text processing and word processing systems </li></ul><ul><li>typically require add...
GML <ul><li>:h1.Chapter 1:  Introduction </li></ul><ul><li>:p.GML supported hierarchical containers, such as </li></ul><ul...
<ul><li>:eol. </li></ul><ul><li>::ol. </li></ul><ul><li></ol> </li></ul>
Brian Reid’s Scribe <ul><li>@Quote(Any damn fool) </li></ul><ul><li>( )  [ ]  { }  </li></ul><ul><li>< >  &quot; &quot;  '...
Scribe <ul><li>@techreport(PUB, key=&quot;Tesler&quot;, author=&quot;Tesler, Larry&quot;,  title=&quot;PUB: The Document C...
License MIT
The Software shall be used  for Good, not Evil. I'm looking at you, Osama bin Laden.
I give permission to IBM,  its customers, partners, and minions, to use JSLint for evil.  Thanks very much, Douglas!  Staf...
The JSON Logo
The Impossible Torus
Ambihelical Hexnut
 
 
 
 
www.JSON.org
Upcoming SlideShare
Loading in...5
×

Douglas Crockford Presentation Jsonsaga

1,613

Published on

Published in: Travel, Spiritual
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,613
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
80
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Douglas Crockford Presentation Jsonsaga

  1. 1. The JSON Saga Douglas Crockford Yahoo! Inc.
  2. 2. I am a heretic. You have been warned.
  3. 3. I Discovered JSON <ul><li>I do not claim to have invented JSON. It already existed in nature. </li></ul><ul><li>I do not claim to have been the first to discover it. </li></ul><ul><li>I gave it a specification and a little website. </li></ul><ul><li>The rest happened by itself. </li></ul>
  4. 4. 2001
  5. 5. State Software 2002
  6. 6. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do:&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  7. 7. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do:&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  8. 8. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do:&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  9. 9. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do:&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  10. 10. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do:&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  11. 11. The Very First JSON Message April 2001 <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{to:&quot;session&quot;, do :&quot;test&quot;, text:&quot;Hello world&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  12. 12. The unquoted name problem <ul><li>ES3 has a wack reserved word policy. </li></ul><ul><li>Reserved words must be quoted. </li></ul><ul><li>I did not want to put the list of reserved words in the JSON spec, so... </li></ul><ul><li>All keys must be quoted. </li></ul><ul><li>It significantly simplified JSON. </li></ul><ul><li>This conforms to Python. </li></ul>
  13. 13. Nested HTML <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{&quot; to &quot;:&quot;session&quot;, &quot; do &quot;:&quot;test&quot;, &quot; text &quot;:&quot; </script> &quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  14. 14. Nested HTML <ul><li><html><head><script> </li></ul><ul><li>document.domain = 'fudco.com'; </li></ul><ul><li>parent.session.receive( </li></ul><ul><li>{&quot; to &quot;:&quot;session&quot;, &quot; do &quot;:&quot;test&quot;, &quot; text &quot;:&quot;< /script>&quot;} </li></ul><ul><li>); </li></ul><ul><li></script></head></html> </li></ul>
  15. 15. JSML JavaScript Message Language
  16. 16. JSON JavaScript Object Notation
  17. 17. JSON was really useful <ul><li>Browser/server communication. </li></ul><ul><li>Interserver communication. </li></ul><ul><li>Configuration. </li></ul><ul><li>JSON database. </li></ul>
  18. 18. Our customers said <ul><li>“Never heard of it.” </li></ul><ul><li>“Sorry, our company just committed to XML.” </li></ul><ul><li>“It is not a standard.” </li></ul>
  19. 19. I bought JSON.org <ul><li>A one-page web site that described JSON. </li></ul><ul><li>Grammar three ways </li></ul><ul><ul><li>Simplified BNF </li></ul></ul><ul><ul><li>Railroad diagrams </li></ul></ul><ul><ul><li>Informal English </li></ul></ul><ul><li>A Java reference implementation. </li></ul><ul><li>And then I retired. </li></ul>
  20. 20. And that’s all I did. A message format in a bottle.
  21. 21. Contributors
  22. 22. Languages <ul><li>ActionScript </li></ul><ul><li>C </li></ul><ul><li>C++ </li></ul><ul><li>C# </li></ul><ul><li>ColdFusion </li></ul><ul><li>D </li></ul><ul><li>Delphi </li></ul><ul><li>E </li></ul><ul><li>Eiffel </li></ul><ul><li>Erlang </li></ul><ul><li>Fan </li></ul><ul><li>Flex </li></ul><ul><li>Haskell </li></ul><ul><li>haXe </li></ul><ul><li>Java </li></ul><ul><li>JavaScript </li></ul><ul><li>Lasso </li></ul><ul><li>Lisp </li></ul><ul><li>LotusScript </li></ul><ul><li>Lua </li></ul><ul><li>Objective C </li></ul><ul><li>Objective CAML </li></ul><ul><li>OpenLaszlo </li></ul><ul><li>Perl </li></ul><ul><li>PHP </li></ul><ul><li>Pike </li></ul><ul><li>pl/sql </li></ul><ul><li>PowerShell </li></ul><ul><li>Prolog </li></ul><ul><li>Python </li></ul><ul><li>R </li></ul><ul><li>REALbasic </li></ul><ul><li>Rebol </li></ul><ul><li>Ruby </li></ul><ul><li>Scheme </li></ul><ul><li>Squeak </li></ul><ul><li>Tcl </li></ul><ul><li>Visual Basic </li></ul><ul><li>Visual FoxPro </li></ul>
  23. 23. JSON is the intersection of modern programming languages <ul><li>Simple values </li></ul><ul><ul><li>number </li></ul></ul><ul><ul><li>string </li></ul></ul><ul><ul><li>boolean </li></ul></ul><ul><li>Sequence of values </li></ul><ul><ul><li>array, vector, list </li></ul></ul><ul><li>Collection of named values </li></ul><ul><ul><li>object, record, struct, hash, property list </li></ul></ul>
  24. 24. Recursive descent <ul><li>value = function () { </li></ul><ul><li>// Parse a JSON value. It could be an object, an array, </li></ul><ul><li>// a string, a number, or a word. </li></ul><ul><li>white(); </li></ul><ul><li>switch (ch) { </li></ul><ul><li>case '{': </li></ul><ul><li>return object(); </li></ul><ul><li>case '[': </li></ul><ul><li>return array(); </li></ul><ul><li>case '&quot;': </li></ul><ul><li>return string(); </li></ul><ul><li>case '-': </li></ul><ul><li>return number(); </li></ul><ul><li>default: </li></ul><ul><li>return ch >= '0' && ch <= '9' ? number() : word(); </li></ul><ul><li>} </li></ul><ul><li>}; </li></ul>
  25. 25. State Machine <ul><li>state = 'go'; </li></ul><ul><li>stack = []; </li></ul><ul><li>try { </li></ul><ul><li>for (;;) { </li></ul><ul><li>r = tx.exec(source); </li></ul><ul><li>if (!r) { </li></ul><ul><li>break; </li></ul><ul><li>} </li></ul><ul><li>if (r[1]) { </li></ul><ul><li>action[r[1]][state](); </li></ul><ul><li>} else if (r[2]) { </li></ul><ul><li>value = +r[2]; </li></ul><ul><li>number[state](); </li></ul><ul><li>} else { </li></ul><ul><li>value = debackslashify(r[3]); </li></ul><ul><li>string[state](); </li></ul><ul><li>} </li></ul><ul><li>source = source.slice(r[0].length); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  26. 26. Eval <ul><li>if ( /^[],:{}s]*$/ .test(text.replace( </li></ul><ul><li>/?:[&quot;bfnrt]|u[0-9a-fA-F]{4})/g , '@').replace( </li></ul><ul><li>/&quot;[^&quot;\ ]*&quot;|true|false|null|-?d+(?:.d*)?(?:[eE][+-]?d+)?/g , ']'). </li></ul><ul><li>replace( /(?:^|:|,)(?:s*[)+/g , ''))) { </li></ul><ul><li>// In the third stage we use the eval function to compile the </li></ul><ul><li>// text into a JavaScript structure. The '{' operator is subject </li></ul><ul><li>// to a syntactic ambiguity in JavaScript: it can begin a block </li></ul><ul><li>// or an object literal. We wrap the text in parens to eliminate </li></ul><ul><li>// the ambiguity. </li></ul><ul><li>j = eval ('(' + text + ')'); </li></ul>
  27. 27. JSON.parse <ul><li>Part of ECMAScript, Fifth Edition </li></ul><ul><li>Available now in better browsers everywhere. </li></ul><ul><li>Very fast. Very reliable. </li></ul>
  28. 28. Languages <ul><li>Arabic </li></ul><ul><li>Bulgarian </li></ul><ul><li>Chinese </li></ul><ul><li>Czech </li></ul><ul><li>Dutch </li></ul><ul><li>French </li></ul><ul><li>German </li></ul><ul><li>Greek </li></ul><ul><li>Hebrew </li></ul><ul><li>Hungarian </li></ul><ul><li>Indonesian </li></ul><ul><li>Italian </li></ul><ul><li>Japanese </li></ul><ul><li>Korean </li></ul><ul><li>Persian </li></ul><ul><li>Polish </li></ul><ul><li>Portuguese </li></ul><ul><li>Russian </li></ul><ul><li>Slovenian </li></ul><ul><li>Spanish </li></ul><ul><li>Turkish </li></ul><ul><li>Vietnamese </li></ul>
  29. 29. Ajax! 2005
  30. 30. Improvements <ul><li>Removed comments. </li></ul><ul><ul><li>Dangerous practices </li></ul></ul><ul><ul><li>Unnecessary complexity </li></ul></ul><ul><ul><li>Alignment with YAML </li></ul></ul><ul><li>Added e notation to numbers. </li></ul>
  31. 31. No version number. <ul><li>JSON will not be changed. </li></ul><ul><li>Stability is more important than any feature we can think of. </li></ul><ul><li>Perhaps someday it will be replaced. </li></ul>
  32. 32. Minimalism It can fit on the back of a business card.
  33. 33. Influences
  34. 34. Lisp S-expressions 1958
  35. 35. Rebol
  36. 36. JavaScript Python NewtonScript
  37. 37. NeXT OpenStep Property Lists 1993
  38. 38. XML The High Priced Spread
  39. 39. HTML Always bet on angle brackets.
  40. 40. Ask not if it is good enough. Ask if it can be popular enough.
  41. 41. Maybe only something this simple could work. John Seely Brown CTO Forum, San Francisco April 2002
  42. 42. Maybe only something this complicated could work. InfoWorld Next-Generation Web Services II: The Applications Santa Clara September 2002
  43. 43. XMLsucks.org Why XML is technologically terrible, but you have to use it anyway
  44. 44. XML is the standard so shut up. SHUT UP!
  45. 45. XML Alternatives <ul><li>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 </li></ul><ul><li>http://www.pault.com/pault/pxml/xmlalternatives.html </li></ul>
  46. 46. Disruption Threats
  47. 47. It’s not even XML! Who did this travesty? Let’s find a tree and string them up. Now. Dave Winer, 2006-12-20
  48. 48. any damn fool could produce a better data format than XML James Clark, 2007-04-06
  49. 49. Use the right tool for the right job. When your only tool is a wrench, every problem looks like a nail.
  50. 50. Where did the idea come from that data should be represented by a document format?
  51. 51. RUNOFF <ul><li>.SK 1 </li></ul><ul><li>Text processing and word processing systems </li></ul><ul><li>typically require additional information to </li></ul><ul><li>be interspersed among the natural text of </li></ul><ul><li>the document being processed. This added </li></ul><ul><li>information, called &quot;markup&quot;, serves two </li></ul><ul><li>purposes: </li></ul><ul><li>.TB 4 </li></ul><ul><li>.OF 4 </li></ul><ul><li>.SK 1 </li></ul><ul><li>1.#Separating the logical elements of the </li></ul><ul><li>document; and </li></ul><ul><li>.OF 4 </li></ul><ul><li>.SK 1 </li></ul><ul><li>2.#Specifying the processing functions to be </li></ul><ul><li>performed on those elements. </li></ul><ul><li>.OF 0 </li></ul><ul><li>.SK 1 </li></ul>
  52. 52. GML <ul><li>:h1.Chapter 1: Introduction </li></ul><ul><li>:p.GML supported hierarchical containers, such as </li></ul><ul><li>:ol </li></ul><ul><li>:li.Ordered lists (like this one), </li></ul><ul><li>:li.Unordered lists, and </li></ul><ul><li>:li.Definition lists </li></ul><ul><li>:eol. </li></ul><ul><li>as well as simple structures. </li></ul><ul><li>:p.Markup minimization (later generalized and </li></ul><ul><li>formalized in SGML), </li></ul><ul><li>allowed the end-tags to be omitted for the &quot;h1&quot; </li></ul><ul><li>and &quot;p&quot; elements. </li></ul>
  53. 53. <ul><li>:eol. </li></ul><ul><li>::ol. </li></ul><ul><li></ol> </li></ul>
  54. 54. Brian Reid’s Scribe <ul><li>@Quote(Any damn fool) </li></ul><ul><li>( ) [ ] { } </li></ul><ul><li>< > &quot; &quot; ' ' </li></ul><ul><li>@Begin(Quote) </li></ul><ul><li>Any damn fool </li></ul><ul><li>@End(Quote) </li></ul><ul><li>1980 </li></ul>
  55. 55. Scribe <ul><li>@techreport(PUB, key=&quot;Tesler&quot;, author=&quot;Tesler, Larry&quot;, title=&quot;PUB: The Document Compiler&quot;, year=1972, number=&quot;ON-72&quot;, month=&quot;Sep&quot;, institution=&quot;Stanford University Artificial Intelligence Project&quot;) @book(Volume3, key=&quot;Knuth&quot;, </li></ul><ul><li>author=&quot;Knuth, Donald E.&quot;, title=&quot;Sorting and Searching&quot;, publisher=&quot;Addison-Wesley&quot;, year=1973, volume=3, </li></ul><ul><li>series=&quot;The Art of Computer Programming&quot;, address=&quot;Reading, Mass.&quot;) </li></ul>
  56. 56. License MIT
  57. 57. The Software shall be used for Good, not Evil. I'm looking at you, Osama bin Laden.
  58. 58. I give permission to IBM, its customers, partners, and minions, to use JSLint for evil. Thanks very much, Douglas! Staff Attorney, IP Law IBM Corporation
  59. 59. The JSON Logo
  60. 60. The Impossible Torus
  61. 61. Ambihelical Hexnut
  62. 66. www.JSON.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×