SlideShare una empresa de Scribd logo
1 de 69
Descargar para leer sin conexión
The JSON Saga
   Douglas Crockford
      Yahoo! Inc.
I am a heretic.

You have been warned.
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.
2001
State Software




2002
The Very First JSON Message
           April 2001

<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
           April 2001

<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
           April 2001

<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
           April 2001

<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
           April 2001

<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
           April 2001

<html><head><script>
document.domain = 'fudco.com';
parent.session.receive(
    {to:"session", do:"test",
    text:"Hello world"}
);
</script></head></html>
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.
Nested HTML
<html><head><script>
document.domain = 'fudco.com';
parent.session.receive(
    {"to":"session", "do":"test",
     "text":"</script>"}
);
</script></head></html>
Nested HTML
<html><head><script>
document.domain = 'fudco.com';
parent.session.receive(
    {"to":"session", "do":"test",
     "text":"</script>"}
);
</script></head></html>
JSML

JavaScript Message Language
JSON

JavaScript 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 bought JSON.org
• A one-page web site that described JSON.
• Grammar three ways
    Simplified BNF
    Railroad diagrams
    Informal English
• A Java reference implementation.

• And then I retired.
And that’s all I did.

A message format in a bottle.
Contributors
Languages
•   ASP                 •   Objective CAML
•   ActionScript        •   OpenLaszlo
•   C                   •   Perl
•   C++                 •   PHP
•   C#                  •   Pike
•   ColdFusion          •   PL/SQL
•   D                   •   pljson
•   Delphi              •   PowerShell
•   E                   •   Prolog
•   Eiffel              •   Python
•   Erlang              •   Qt
•   Fantom              •   R
•   Go                  •   REALbasic
•   Haskell             •   Rebol
•   haXe                •   RPG
•   Java                •   Ruby
•   JavaScript          •   Scheme
•   Lasso               •   Squeak
•   Lisp                •   Symbian
•   LotusScript         •   Tcl
•   Lua                 •   Visual Basic
•   Objective C         •   Visual FoxPro
JSON is the intersection of modern
    programming languages

• Simple values
    number
    string
    boolean
• Sequence of values
    array, vector, list
• Collection of named values
    object, record, struct, map, hash, property list
Recursive descent
   value = 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();
        }
   };
State Machine
state = '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);
    }
}
Eval
    if (/^[],:{}s]*$/.test(text.replace(
            /(?:["/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(
/"[^"nr]*"|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 + ')');
JSON.parse
• Part of ECMAScript, Fifth Edition
• Available now in better browsers
  everywhere.
• Very fast. Very reliable.
Languages
•   Arabic            •   Italian
•   Bulgarian         •   Japanese
•   Chinese           •   Korean
•   Czech             •   Persian
•   Dutch             •   Polish
•   French            •   Portuguese
•   German            •   Russian
•   Greek             •   Slovenian
•   Hebrew            •   Spanish
•   Hungarian         •   Turkish
•   Indonesian        •   Vietnamese
2005
Improvements
• Removed comments.
   Dangerous practices
   Unnecessary complexity
   Alignment with YAML
• Added e notation to numbers.
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.
RFC 4627

application/json
Minimalism

It can fit on the back of a business card.
The less we need to agree on,
the easier it is to interoperate.
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
         September 2002
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
• 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
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
.SK 1
Text processing and word processing systems
typically require additional information to
be interspersed among the natural text of
the document being processed. This added
information, called "markup", serves two
purposes:
.TB 4
.OF 4
.SK 1
1.#Separating the logical elements of the
document; and
.OF 4
.SK 1
2.#Specifying the processing functions to be
performed on those elements.
.OF 0
.SK 1
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.
:eol.

::ol.

</ol>
Brian Reid’s Scribe
@Quote(Any damn fool)

    ( )    [ ]   { }
    < >    " "   ' '

@Begin(Quote)
    Any damn fool
@End(Quote)

                    1980
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.")
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!

    Staff Attorney, IP Law
      IBM Corporation
The JSON Logo
The Impossible Torus
Ambihelical Hexnut
www.JSON.org

Más contenido relacionado

La actualidad más candente

Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]
Karel Minarik
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 

La actualidad más candente (20)

Basics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesBasics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examples
 
JSON
JSONJSON
JSON
 
Search Engine-Building with Lucene and Solr
Search Engine-Building with Lucene and SolrSearch Engine-Building with Lucene and Solr
Search Engine-Building with Lucene and Solr
 
Free your lambdas
Free your lambdasFree your lambdas
Free your lambdas
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Terms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explainedTerms of endearment - the ElasticSearch Query DSL explained
Terms of endearment - the ElasticSearch Query DSL explained
 
Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)
 
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj TalkSpark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
 
Json - ideal for data interchange
Json - ideal for data interchangeJson - ideal for data interchange
Json - ideal for data interchange
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
 
GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑
 
Javascript
JavascriptJavascript
Javascript
 
Java and XML
Java and XMLJava and XML
Java and XML
 
The emerging world of mongo db csp
The emerging world of mongo db   cspThe emerging world of mongo db   csp
The emerging world of mongo db csp
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Java 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJava 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java Comparison
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 

Similar a Jsonsaga 100605143125-phpapp02

Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation Jsonsaga
Ajax Experience 2009
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaga
nohmad
 
json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
AmitSharma397241
 

Similar a Jsonsaga 100605143125-phpapp02 (20)

Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation Jsonsaga
 
Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax Trees
 
The JSON Saga
The JSON SagaThe JSON Saga
The JSON Saga
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaga
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
 
Avro
AvroAvro
Avro
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
 
Json
JsonJson
Json
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
gRPC & Kubernetes
gRPC & KubernetesgRPC & Kubernetes
gRPC & Kubernetes
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Apache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos LinardosApache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos Linardos
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
Serializing EMF models with Xtext
Serializing EMF models with XtextSerializing EMF models with Xtext
Serializing EMF models with Xtext
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Jsonsaga 100605143125-phpapp02

  • 1. The JSON Saga Douglas Crockford Yahoo! Inc.
  • 2. I am a heretic. You have been warned.
  • 3. 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.
  • 6. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 7. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 8. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 9. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 10. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 11. The Very First JSON Message April 2001 <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {to:"session", do:"test", text:"Hello world"} ); </script></head></html>
  • 12. 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.
  • 13. Nested HTML <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {"to":"session", "do":"test", "text":"</script>"} ); </script></head></html>
  • 14. Nested HTML <html><head><script> document.domain = 'fudco.com'; parent.session.receive( {"to":"session", "do":"test", "text":"</script>"} ); </script></head></html>
  • 17. JSON was really useful • Browser/server communication. • Interserver communication. • Configuration. • JSON database.
  • 18. Our customers said • “Never heard of it.” • “Sorry, our company just committed to XML.” • “It is not a standard.”
  • 19. I bought JSON.org • A one-page web site that described JSON. • Grammar three ways Simplified BNF Railroad diagrams Informal English • A Java reference implementation. • And then I retired.
  • 20. And that’s all I did. A message format in a bottle.
  • 22. Languages • ASP • Objective CAML • ActionScript • OpenLaszlo • C • Perl • C++ • PHP • C# • Pike • ColdFusion • PL/SQL • D • pljson • Delphi • PowerShell • E • Prolog • Eiffel • Python • Erlang • Qt • Fantom • R • Go • REALbasic • Haskell • Rebol • haXe • RPG • Java • Ruby • JavaScript • Scheme • Lasso • Squeak • Lisp • Symbian • LotusScript • Tcl • Lua • Visual Basic • Objective C • Visual FoxPro
  • 23. JSON is the intersection of modern programming languages • Simple values number string boolean • Sequence of values array, vector, list • Collection of named values object, record, struct, map, hash, property list
  • 24. Recursive descent value = 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(); } };
  • 25. State Machine state = '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); } }
  • 26. Eval if (/^[],:{}s]*$/.test(text.replace( /(?:["/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace( /"[^"nr]*"|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 + ')');
  • 27. JSON.parse • Part of ECMAScript, Fifth Edition • Available now in better browsers everywhere. • Very fast. Very reliable.
  • 28. Languages • Arabic • Italian • Bulgarian • Japanese • Chinese • Korean • Czech • Persian • Dutch • Polish • French • Portuguese • German • Russian • Greek • Slovenian • Hebrew • Spanish • Hungarian • Turkish • Indonesian • Vietnamese
  • 29. 2005
  • 30. Improvements • Removed comments. Dangerous practices Unnecessary complexity Alignment with YAML • Added e notation to numbers.
  • 31. 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.
  • 33. Minimalism It can fit on the back of a business card.
  • 34. The less we need to agree on, the easier it is to interoperate.
  • 37. Rebol
  • 38. JavaScript Python NewtonScript
  • 41. HTML Always bet on angle brackets.
  • 42. Ask not if it is good enough. Ask if it can be popular enough.
  • 43. Maybe only something this simple could work. John Seely Brown CTO Forum, San Francisco April 2002
  • 44. Maybe only something this complicated could work. InfoWorld Next-Generation Web Services II: The Applications Santa Clara September 2002
  • 45. XMLsucks.org Why XML is technologically terrible, but you have to use it anyway
  • 46. XML is the standard so shut up. SHUT UP!
  • 47. 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
  • 49. It’s not even XML! Who did this travesty? Let’s find a tree and string them up. Now. Dave Winer, 2006-12-20
  • 50. any damn fool could produce a better data format than XML James Clark, 2007-04-06
  • 51. Use the right tool for the right job. When your only tool is a wrench, every problem looks like a nail.
  • 52. Where did the idea come from that data should be represented by a document format?
  • 53. RUNOFF .SK 1 Text processing and word processing systems typically require additional information to be interspersed among the natural text of the document being processed. This added information, called "markup", serves two purposes: .TB 4 .OF 4 .SK 1 1.#Separating the logical elements of the document; and .OF 4 .SK 1 2.#Specifying the processing functions to be performed on those elements. .OF 0 .SK 1
  • 54. 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.
  • 56. Brian Reid’s Scribe @Quote(Any damn fool) ( ) [ ] { } < > " " ' ' @Begin(Quote) Any damn fool @End(Quote) 1980
  • 57. 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.")
  • 59. The Software shall be used for Good, not Evil. I'm looking at you, Osama bin Laden.
  • 60. I give permission to IBM, its customers, partners, and minions, to use JSLint for evil.
  • 61. Thanks very much, Douglas! Staff Attorney, IP Law IBM Corporation
  • 65.
  • 66.
  • 67.
  • 68.