SlideShare uma empresa Scribd logo
1 de 69
JSON
The x in Ajax
Data Interchange
ā€¢ The key idea in Ajax.
ā€¢ An alternative to page
replacement.
ā€¢ Applications delivered as pages.
ā€¢ How should the data be
delivered?
History of Data Formats
ā€¢ Ad Hoc
ā€¢ Database Model
ā€¢ Document Model
ā€¢ Programming Language Model
JSON
ā€¢ JavaScript Object Notation
ā€¢ Minimal
ā€¢ Textual
ā€¢ Subset of JavaScript
JSON
ā€¢ A Subset of ECMA-262 Third Edition.
ā€¢ Language Independent.
ā€¢ Text-based.
ā€¢ Light-weight.
ā€¢ Easy to parse.
JSON Is Not...
ā€¢ JSON is not a document format.
ā€¢ JSON is not a markup language.
ā€¢ JSON is not a general
serialization format.
No cyclical/recurring structures.
No invisible structures.
No functions.
History
ā€¢ 1999 ECMAScript Third Edition
ā€¢ 2001 State Software, Inc.
ā€¢ 2002 JSON.org
ā€¢ 2005 Ajax
ā€¢ 2006 RFC 4627
Languages
ā€¢ Chinese
ā€¢ English
ā€¢ French
ā€¢ German
ā€¢ Italian
ā€¢ Japanese
ā€¢ Korean
Languages
ā€¢ ActionScript
ā€¢ C / C++
ā€¢ C#
ā€¢ Cold Fusion
ā€¢ Delphi
ā€¢ E
ā€¢ Erlang
ā€¢ Java
ā€¢ Lisp
ā€¢ Perl
ā€¢ Objective-C
ā€¢ Objective CAML
ā€¢ PHP
ā€¢ Python
ā€¢ Rebol
ā€¢ Ruby
ā€¢ Scheme
ā€¢ Squeak
Object Quasi-Literals
ā€¢ JavaScript
ā€¢ Python
ā€¢ NewtonScript
Values
ā€¢ Strings
ā€¢ Numbers
ā€¢ Booleans
ā€¢ Objects
ā€¢ Arrays
ā€¢ null
Value
Strings
ā€¢ Sequence of 0 or more Unicode
characters
ā€¢ No separate character type
A character is represented as a
string with a length of 1
ā€¢ Wrapped in "double quotes"
ā€¢ Backslash escapement
String
Numbers
ā€¢ Integer
ā€¢ Real
ā€¢ Scientific
ā€¢ No octal or hex
ā€¢ No NaN or Infinity
Use null instead
Number
Booleans
ā€¢ true
ā€¢ false
null
ā€¢ A value that isn't anything
Object
ā€¢ Objects are unordered containers
of key/value pairs
ā€¢ Objects are wrapped in { }
ā€¢ , separates key/value pairs
ā€¢ : separates keys and values
ā€¢ Keys are strings
ā€¢ Values are JSON values
struct, record, hashtable, object
Object
Object
{"name":"Jack B. Nimble","at large":
true,"grade":"A","level":3, "format":
{"type":"rect","width":1920,
"height":1080,"interlace":false,
"framerate":24}}
Object
{
"name": "Jack B. Nimble",
"at large": true,
"grade": "A",
"format": {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"framerate": 24
}
}
Array
ā€¢ Arrays are ordered sequences of
values
ā€¢ Arrays are wrapped in []
ā€¢ , separates values
ā€¢ JSON does not talk about
indexing.
An implementation can start array
indexing at 0 or 1.
Array
Array
["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday",
"Friday", "Saturday"]
[
[0, -1, 0],
[1, 0, 0],
[0, 0, 1]
]
Arrays vs Objects
ā€¢ Use objects when the key names
are arbitrary strings.
ā€¢ Use arrays when the key names
are sequential integers.
ā€¢ Don't get confused by the term
Associative Array.
MIME Media Type
application/json
Character Encoding
ā€¢ Strictly UNICODE.
ā€¢ Default: UTF-8.
ā€¢ UTF-16 and UTF-32 are allowed.
Versionless
ā€¢ JSON has no version number.
ā€¢ No revisions to the JSON
grammar are anticipated.
ā€¢ JSON is very stable.
Rules
ā€¢ A JSON decoder must accept all
well-formed JSON text.
ā€¢ A JSON decoder may also accept
non-JSON text.
ā€¢ A JSON encoder must only
produce well-formed JSON text.
ā€¢ Be conservative in what you do,
be liberal in what you accept from
others.
Supersets
ā€¢ YAML is a superset of JSON.
A YAML decoder is a JSON decoder.
ā€¢ JavaScript is a superset of JSON.
A JavaScript compiler is a JSON
decoder.
ā€¢ New programming languages
based on JSON.
JSON is the X in Ajax
JSON in Ajax
ā€¢ HTML Delivery.
ā€¢ JSON data is built into the page.
<html>...
<script>
var data = { ... JSONdata ... };
</script>...
</html>
JSON in Ajax
ā€¢ XMLHttpRequest
Obtain responseText
Parse the responseText
responseData = eval(
'(' + responseText + ')');
responseData =
responseText.parseJSON();
JSON in Ajax
ā€¢ Is it safe to use eval with
XMLHttpRequest?
ā€¢ The JSON data comes from the
same server that vended the
page. eval of the data is no less
secure than the original html.
ā€¢ If in doubt, use string.parseJSON
instead of eval.
JSON in Ajax
ā€¢ Secret <iframe>
ā€¢ Request data using form.submit to the
<iframe> target.
ā€¢ The server sends the JSON text
embedded in a script in a document.
<html><head><script>
document.domain = 'penzance.com';
parent.deliver({ ... JSONtext ... });
</script></head></html>
ā€¢ The function deliver is passed the
value.
JSON in Ajax
ā€¢ Dynamic script tag hack.
ā€¢ Create a script node. The src url
makes the request.
ā€¢ The server sends the JSON text
embedded in a script.
deliver({ ... JSONtext ... });
ā€¢ The function deliver is passed
the value.
ā€¢ The dynamic script tag hack is
insecure.
JSONRequest
ā€¢ A new facility.
ā€¢ Two way data interchange
between any page and any server.
ā€¢ Exempt from the Same Origin
Policy.
ā€¢ Campaign to make a standard
feature of all browsers.
JSONRequest
function done(requestNr, value, exception) {
...
}
var request =
JSONRequest.post(url, data, done);
var request =
JSONRequest.get(url, done);
ā€¢ No messing with headers.
ā€¢ No cookies.
ā€¢ No implied authentication.
JSONRequest
ā€¢ Requests are transmitted in order.
ā€¢ Requests can have timeouts.
ā€¢ Requests can be cancelled.
ā€¢ Connections are in addition to the
browser's ordinary two connections per
host.
ā€¢ Support for asynchronous, full duplex
JSONRequest
ā€¢ Tell your favorite browser maker
I want JSONRequest!
http://www.JSON.org/JSONRequest.html
ECMAScript Fourth Ed.
ā€¢ New Methods:
Object.prototype.toJSONString
String.prototype.parseJSON
ā€¢ Available now: JSON.org/json.js
supplant
var template = '<table border="{border}">' +
'<tr><th>Last</th><td>{last}</td></tr>' +
'<tr><th>First</th><td>{first}</td></tr>' +
'</table>';
var data = {
"first": "Carl",
"last": "Hollywood",
"border": 2
};
mydiv.innerHTML = template.supplant(data);
supplant
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' ?
r : a;
}
);
};
JSONT
var rules = {
self:
'<svg><{closed} stroke="{color}" points="{points}" /></svg>',
closed: function (x) {return x ? 'polygon' : 'polyline';},
'points[*][*]': '{$} '
};
var data = {
"color": "blue",
"closed": true,
"points": [[10,10], [20,10], [20,20], [10,20]]
};
jsonT(data, rules)
<svg><polygon stroke="blue"
points="10 10 20 10 20 20 10 20 " /></svg>
http://goessner.net/articles/jsont/
function jsonT(self, rules) {
var T = {
output: false,
init: function () {
for (var rule in rules) if (rule.substr(0,4) != "self") rules["self." + rule] = rules[rule];
return this;
},
apply: function(expr) {
var trf = function (s) {
return s.replace(/{([A-Za-z0-9_$.[]'@()]+)}/g, function ($0, $1){
return T.processArg($1, expr);
})
}, x = expr.replace(/[[0-9]+]/g, "[*]"), res;
if (x in rules) {
if (typeof(rules[x]) == "string") res = trf(rules[x]);
else if (typeof(rules[x]) == "function") res = trf(rules[x](eval(expr)).toString());
} else res = T.eval(expr);
return res;
},
processArg: function (arg, parentExpr) {
var expand = function (a, e) {
return (e = a.replace(/^$/,e)).substr(0, 4) != "self" ? ("self." + e) : e;
}, res = "";
T.output = true;
if (arg.charAt(0) == "@") res = eval(arg.replace(/@([A-za-z0-9_]+)(([A-Za-z0-9_$.[]']+))/, function($0, $1, $2){
return "rules['self." + $1 + "'](" + expand($2,parentExpr) + ")";
}));
else if (arg != "$") res = T.apply(expand(arg, parentExpr));
else res = T.eval(parentExpr);
T.output = false;
return res;
},
eval: function (expr) {
var v = eval(expr), res = "";
if (typeof(v) != "undefined") {
if (v instanceof Array) {
for (var i = 0; i < v.length; i++) if (typeof(v[i]) != "undefined") res += T.apply(expr + "[" + i + "]");
} else if (typeof(v) == "object") {
for (var m in v) if (typeof(v[m]) != "undefined") res += T.apply(expr+"."+m);
} else if (T.output) res += v;
}
return res;
}
};
return T.init().apply("self");
}
Some features that make it
well-suited for data transfer
ā€¢ It's simultaneously human- and machine-
readable format;
ā€¢ It has support for Unicode, allowing almost
any information in any human language to be
communicated;
ā€¢ The self-documenting format that describes
structure and field names as well as specific
values;
ā€¢ The strict syntax and parsing requirements
that allow the necessary parsing algorithms
to remain simple, efficient, and consistent;
ā€¢ The ability to represent the most general
computer science data structures: records,
lists and trees.
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...
Arguments against JSON
ā€¢ JSON Doesn't Have Namespaces.
ā€¢ JSON Has No Validator.
ā€¢ JSON Is Not Extensible.
ā€¢ JSON Is Not XML.
JSON Doesn't Have
Namespaces
ā€¢ Every object is a namespace. Its
set of keys is independent of all
other objects, even exclusive of
nesting.
ā€¢ JSON uses context to avoid
ambiguity, just as programming
languages do.
Namespace
ā€¢ http://www.w3c.org/TR/REC-xml-names/
ā€¢ In this example, there are three occurrences of the
name title within the markup, and the name alone
clearly provides insufficient information to allow
correct processing by a software module.
<section>
<title>Book-Signing Event</title>
<signing>
<author title="Mr" name="Vikram Seth" />
<book title="A Suitable Boy" price="$22.95" />
</signing>
<signing>
<author title="Dr" name="Oliver Sacks" />
<book title="The Island of the Color-Blind"
price="$12.95" />
</signing>
Namespace
{"section":
"title": "Book-Signing Event",
"signing": [
{
"author": { "title": "Mr", "name": "Vikram Seth" },
"book": { "title": "A Suitable Boy",
"price": "$22.95" }
}, {
"author": { "title": "Dr", "name": "Oliver Sacks" },
"book": { "title": "The Island of the Color-Blind",
"price": "$12.95" }
}
]
}}
ā€¢ section.title
ā€¢ section.signing[0].author.title
ā€¢ section.signing[1].book.title
JSON Has No Validator
ā€¢ Being well-formed and valid is not
the same as being correct and
relevant.
ā€¢ Ultimately, every application is
responsible for validating its
inputs. This cannot be delegated.
ā€¢ A YAML validator can be used.
JSON is Not Extensible
ā€¢ It does not need to be.
ā€¢ It can represent any non-recurrent
data structure as is.
ā€¢ JSON is flexible. New fields can
be added to existing structures
without obsoleting existing
programs.
JSON Is Not XML
ā€¢ objects
ā€¢ arrays
ā€¢ strings
ā€¢ numbers
ā€¢ booleans
ā€¢ null
ā€¢ element
ā€¢ attribute
ā€¢ attribute string
ā€¢ content
ā€¢ <![CDATA[ ]]>
ā€¢ entities
ā€¢ declarations
ā€¢ schema
ā€¢ stylesheets
ā€¢ comments
ā€¢ version
ā€¢ namespace
Data Interchange
ā€¢ JSON is a simple, common
representation of data.
ā€¢ Communication between servers
and browser clients.
ā€¢ Communication between peers.
ā€¢ Language independent data
Why the Name?
ā€¢ XML is not a good data
interchange format, but it is a
document standard.
ā€¢ Having a standard to refer to
eliminates a lot of squabbling.
Going Meta
ā€¢ By adding one level of meta-
encoding, JSON can be made to
do the things that JSON can't do.
ā€¢ Recurrent and recursive
structures.
ā€¢ Values beyond the ordinary base
values.
Going Meta
ā€¢ Simply replace the troublesome
structures and values with an
object which describes them.
{
"$META$": meta-type,
"value": meta-value
}
Going Meta
ā€¢ Possible meta-types:
"label" Label a structure
for reuse.
"ref" Reuse a structure.
"class" Associate a class
with a structure.
"type" Associate a special
type, such as Date,
with a structure.
Browser Innovation
ā€¢ During the Browser War,
innovation was driven by the
browser makers.
ā€¢ In the Ajax Age, innovation is
being driven by application
developers.
ā€¢ The browser makers are falling
behind.
The Mashup Security
Problem
ā€¢ Mashups are an interesting new
way to build applications.
ā€¢ Mashups do not work when any of
the modules or widgets contains
information that is private or
represents a connection which is
private.
The Mashup Security
Problem
ā€¢ JavaScript and the DOM provide
completely inadequate levels of
security.
ā€¢ Mashups require a security model
that provides cooperation under
mutual suspicion.
The Mashup Security
Solution
<module id="NAME" href="URL"
style="STYLE" />
ā€¢ A module is like a restricted iframe.
The parent script is not allowed access
to the module's window object. The
module's script is not allowed access
to the parent's window object.
The Mashup Security
Solution
<module id="NAME" href="URL" style="STYLE" />
ā€¢ The module node presents a send
method which allows for sending a
JSON string to the module script.
ā€¢ The module node can accept a receive
method which allows for receiving a
JSON string from the module script.
The Mashup Security
Solution
<module id="NAME" href="URL" style="STYLE" />
ā€¢ Inside the module, there is a global
send function which allows for sending
a JSON string to the outer document's
script.
ā€¢ Inside the module, you can define a
receive method which allows for
receiving a JSON string from the outer
document's script.
The Mashup Security
Solution
<module id="NAME" href="URL" style="STYLE" />
The Mashup Security
Solution
<module id="NAME" href="URL" style="STYLE" />
ā€¢ Communiciation is permitted only
through cooperating send and
receive functions.
ā€¢ The module is exempt from the
Same Origin Policy.
The Mashup Security
Solution
<module id="NAME" href="URL" style="STYLE" />
ā€¢ Ask your favorite browser maker
for the <module> tag.

Mais conteĆŗdo relacionado

Mais procurados

J s-o-n-120219575328402-3
J s-o-n-120219575328402-3J s-o-n-120219575328402-3
J s-o-n-120219575328402-3
Ramamohan Chokkam
Ā 
Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
Ā 
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
GeeksLab Odessa
Ā 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
Kumar
Ā 

Mais procurados (20)

J s-o-n-120219575328402-3
J s-o-n-120219575328402-3J s-o-n-120219575328402-3
J s-o-n-120219575328402-3
Ā 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
Ā 
Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02
Ā 
Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)
Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)
Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)
Ā 
Java Performance Tips (So Code Camp San Diego 2014)
Java Performance Tips (So Code Camp San Diego 2014)Java Performance Tips (So Code Camp San Diego 2014)
Java Performance Tips (So Code Camp San Diego 2014)
Ā 
Querring xml with xpath
Querring xml with xpath Querring xml with xpath
Querring xml with xpath
Ā 
Json
JsonJson
Json
Ā 
Xml parsing
Xml parsingXml parsing
Xml parsing
Ā 
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
Ā 
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
Java/Scala Lab 2016. Š“Ń€ŠøŠ³Š¾Ń€ŠøŠ¹ ŠšŃ€Š°Š²Ń†Š¾Š²: Š ŠµŠ°Š»ŠøŠ·Š°Ń†Šøя Šø тŠµŃŃ‚ŠøрŠ¾Š²Š°Š½ŠøŠµ DAO сŠ»Š¾Ń с Š½...
Ā 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
Ā 
Intermediate JavaScript
Intermediate JavaScriptIntermediate JavaScript
Intermediate JavaScript
Ā 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
Ā 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
Ā 
Get the most out of Solr search with PHP
Get the most out of Solr search with PHPGet the most out of Solr search with PHP
Get the most out of Solr search with PHP
Ā 
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJSThe Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
The Road To Damascus - A Conversion Experience: LotusScript and @Formula to SSJS
Ā 
ElasticSearch AJUG 2013
ElasticSearch AJUG 2013ElasticSearch AJUG 2013
ElasticSearch AJUG 2013
Ā 
Sax parser
Sax parserSax parser
Sax parser
Ā 
DOM and SAX
DOM and SAXDOM and SAX
DOM and SAX
Ā 
Dom parser
Dom parserDom parser
Dom parser
Ā 

Destaque

Destaque (6)

Was uns wirklich nƤhrt
Was uns wirklich nƤhrtWas uns wirklich nƤhrt
Was uns wirklich nƤhrt
Ā 
C* Summit 2013: Suicide Risk Prediction Using Social Media and Cassandra by K...
C* Summit 2013: Suicide Risk Prediction Using Social Media and Cassandra by K...C* Summit 2013: Suicide Risk Prediction Using Social Media and Cassandra by K...
C* Summit 2013: Suicide Risk Prediction Using Social Media and Cassandra by K...
Ā 
Elastic Web Mining
Elastic Web MiningElastic Web Mining
Elastic Web Mining
Ā 
Game Programming 03 - Git Flow
Game Programming 03 - Git FlowGame Programming 03 - Git Flow
Game Programming 03 - Git Flow
Ā 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
Ā 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great Game
Ā 

Semelhante a Json - ideal for data interchange

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
Ā 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
AnujSood25
Ā 
ERRest and Dojo
ERRest and DojoERRest and Dojo
ERRest and Dojo
WO Community
Ā 

Semelhante a Json - ideal for data interchange (20)

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
Ā 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
Ā 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and Handlebars
Ā 
Json processing
Json processingJson processing
Json processing
Ā 
JSON - (English)
JSON - (English)JSON - (English)
JSON - (English)
Ā 
JSON
JSONJSON
JSON
Ā 
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)
Ā 
Postgres vs Mongo / ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š² (Postgres Professional)
Postgres vs Mongo / ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š² (Postgres Professional)Postgres vs Mongo / ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š² (Postgres Professional)
Postgres vs Mongo / ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š² (Postgres Professional)
Ā 
Web technologies-course 10.pptx
Web technologies-course 10.pptxWeb technologies-course 10.pptx
Web technologies-course 10.pptx
Ā 
No sql way_in_pg
No sql way_in_pgNo sql way_in_pg
No sql way_in_pg
Ā 
JSON
JSONJSON
JSON
Ā 
Mathias test
Mathias testMathias test
Mathias test
Ā 
AJAX
AJAXAJAX
AJAX
Ā 
The NoSQL Way in Postgres
The NoSQL Way in PostgresThe NoSQL Way in Postgres
The NoSQL Way in Postgres
Ā 
ElasticSearch
ElasticSearchElasticSearch
ElasticSearch
Ā 
Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)
Ā 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
Ā 
Json
JsonJson
Json
Ā 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.
Ā 
ERRest and Dojo
ERRest and DojoERRest and Dojo
ERRest and Dojo
Ā 

Mais de Christoph Santschi

Mais de Christoph Santschi (15)

Yaml
YamlYaml
Yaml
Ā 
Self Assembly
Self AssemblySelf Assembly
Self Assembly
Ā 
Wasser und die Biochemie des Menschen
Wasser und die Biochemie des MenschenWasser und die Biochemie des Menschen
Wasser und die Biochemie des Menschen
Ā 
F sharp - an overview
F sharp - an overviewF sharp - an overview
F sharp - an overview
Ā 
Prinzipien funktionaler programmierung
Prinzipien funktionaler programmierungPrinzipien funktionaler programmierung
Prinzipien funktionaler programmierung
Ā 
Analyse-Methodik
Analyse-MethodikAnalyse-Methodik
Analyse-Methodik
Ā 
Ernaehrung und Gesundheit
Ernaehrung und GesundheitErnaehrung und Gesundheit
Ernaehrung und Gesundheit
Ā 
Schlafstoerung
SchlafstoerungSchlafstoerung
Schlafstoerung
Ā 
Enzyme
EnzymeEnzyme
Enzyme
Ā 
NatĆ¼rliche Schmerzmittel
NatĆ¼rliche SchmerzmittelNatĆ¼rliche Schmerzmittel
NatĆ¼rliche Schmerzmittel
Ā 
Die w fragen
Die w fragenDie w fragen
Die w fragen
Ā 
Vitamin D - das Sonnenvitamin
Vitamin D - das SonnenvitaminVitamin D - das Sonnenvitamin
Vitamin D - das Sonnenvitamin
Ā 
Standortbestimmung ErnƤhrung - Wo sind wir?
Standortbestimmung ErnƤhrung - Wo sind wir?Standortbestimmung ErnƤhrung - Wo sind wir?
Standortbestimmung ErnƤhrung - Wo sind wir?
Ā 
Ad(h)s und Ernaehrung
Ad(h)s und ErnaehrungAd(h)s und Ernaehrung
Ad(h)s und Ernaehrung
Ā 
Projektmanagement
ProjektmanagementProjektmanagement
Projektmanagement
Ā 

ƚltimo

CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
Ā 
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online ā˜‚ļø
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online  ā˜‚ļøCALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online  ā˜‚ļø
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online ā˜‚ļø
anilsa9823
Ā 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
Ā 
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 

ƚltimo (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
Ā 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
Ā 
CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON āž„8923113531 šŸ”Call Girls Badshah Nagar Lucknow best Female service
Ā 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
Ā 
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online ā˜‚ļø
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online  ā˜‚ļøCALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online  ā˜‚ļø
CALL ON āž„8923113531 šŸ”Call Girls Kakori Lucknow best sexual service Online ā˜‚ļø
Ā 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
Ā 
Vip Call Girls Noida āž”ļø Delhi āž”ļø 9999965857 No Advance 24HRS Live
Vip Call Girls Noida āž”ļø Delhi āž”ļø 9999965857 No Advance 24HRS LiveVip Call Girls Noida āž”ļø Delhi āž”ļø 9999965857 No Advance 24HRS Live
Vip Call Girls Noida āž”ļø Delhi āž”ļø 9999965857 No Advance 24HRS Live
Ā 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Ā 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Ā 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Ā 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanā€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanā€™s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanā€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanā€™s ...
Ā 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Ā 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Ā 
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
Ā 

Json - ideal for data interchange

  • 2. Data Interchange ā€¢ The key idea in Ajax. ā€¢ An alternative to page replacement. ā€¢ Applications delivered as pages. ā€¢ How should the data be delivered?
  • 3. History of Data Formats ā€¢ Ad Hoc ā€¢ Database Model ā€¢ Document Model ā€¢ Programming Language Model
  • 4. JSON ā€¢ JavaScript Object Notation ā€¢ Minimal ā€¢ Textual ā€¢ Subset of JavaScript
  • 5. JSON ā€¢ A Subset of ECMA-262 Third Edition. ā€¢ Language Independent. ā€¢ Text-based. ā€¢ Light-weight. ā€¢ Easy to parse.
  • 6. JSON Is Not... ā€¢ JSON is not a document format. ā€¢ JSON is not a markup language. ā€¢ JSON is not a general serialization format. No cyclical/recurring structures. No invisible structures. No functions.
  • 7. History ā€¢ 1999 ECMAScript Third Edition ā€¢ 2001 State Software, Inc. ā€¢ 2002 JSON.org ā€¢ 2005 Ajax ā€¢ 2006 RFC 4627
  • 8. Languages ā€¢ Chinese ā€¢ English ā€¢ French ā€¢ German ā€¢ Italian ā€¢ Japanese ā€¢ Korean
  • 9. Languages ā€¢ ActionScript ā€¢ C / C++ ā€¢ C# ā€¢ Cold Fusion ā€¢ Delphi ā€¢ E ā€¢ Erlang ā€¢ Java ā€¢ Lisp ā€¢ Perl ā€¢ Objective-C ā€¢ Objective CAML ā€¢ PHP ā€¢ Python ā€¢ Rebol ā€¢ Ruby ā€¢ Scheme ā€¢ Squeak
  • 11. Values ā€¢ Strings ā€¢ Numbers ā€¢ Booleans ā€¢ Objects ā€¢ Arrays ā€¢ null
  • 12. Value
  • 13. Strings ā€¢ Sequence of 0 or more Unicode characters ā€¢ No separate character type A character is represented as a string with a length of 1 ā€¢ Wrapped in "double quotes" ā€¢ Backslash escapement
  • 15. Numbers ā€¢ Integer ā€¢ Real ā€¢ Scientific ā€¢ No octal or hex ā€¢ No NaN or Infinity Use null instead
  • 18. null ā€¢ A value that isn't anything
  • 19. Object ā€¢ Objects are unordered containers of key/value pairs ā€¢ Objects are wrapped in { } ā€¢ , separates key/value pairs ā€¢ : separates keys and values ā€¢ Keys are strings ā€¢ Values are JSON values struct, record, hashtable, object
  • 21. Object {"name":"Jack B. Nimble","at large": true,"grade":"A","level":3, "format": {"type":"rect","width":1920, "height":1080,"interlace":false, "framerate":24}}
  • 22. Object { "name": "Jack B. Nimble", "at large": true, "grade": "A", "format": { "type": "rect", "width": 1920, "height": 1080, "interlace": false, "framerate": 24 } }
  • 23. Array ā€¢ Arrays are ordered sequences of values ā€¢ Arrays are wrapped in [] ā€¢ , separates values ā€¢ JSON does not talk about indexing. An implementation can start array indexing at 0 or 1.
  • 24. Array
  • 25. Array ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] [ [0, -1, 0], [1, 0, 0], [0, 0, 1] ]
  • 26. Arrays vs Objects ā€¢ Use objects when the key names are arbitrary strings. ā€¢ Use arrays when the key names are sequential integers. ā€¢ Don't get confused by the term Associative Array.
  • 28. Character Encoding ā€¢ Strictly UNICODE. ā€¢ Default: UTF-8. ā€¢ UTF-16 and UTF-32 are allowed.
  • 29. Versionless ā€¢ JSON has no version number. ā€¢ No revisions to the JSON grammar are anticipated. ā€¢ JSON is very stable.
  • 30. Rules ā€¢ A JSON decoder must accept all well-formed JSON text. ā€¢ A JSON decoder may also accept non-JSON text. ā€¢ A JSON encoder must only produce well-formed JSON text. ā€¢ Be conservative in what you do, be liberal in what you accept from others.
  • 31. Supersets ā€¢ YAML is a superset of JSON. A YAML decoder is a JSON decoder. ā€¢ JavaScript is a superset of JSON. A JavaScript compiler is a JSON decoder. ā€¢ New programming languages based on JSON.
  • 32. JSON is the X in Ajax
  • 33. JSON in Ajax ā€¢ HTML Delivery. ā€¢ JSON data is built into the page. <html>... <script> var data = { ... JSONdata ... }; </script>... </html>
  • 34. JSON in Ajax ā€¢ XMLHttpRequest Obtain responseText Parse the responseText responseData = eval( '(' + responseText + ')'); responseData = responseText.parseJSON();
  • 35. JSON in Ajax ā€¢ Is it safe to use eval with XMLHttpRequest? ā€¢ The JSON data comes from the same server that vended the page. eval of the data is no less secure than the original html. ā€¢ If in doubt, use string.parseJSON instead of eval.
  • 36. JSON in Ajax ā€¢ Secret <iframe> ā€¢ Request data using form.submit to the <iframe> target. ā€¢ The server sends the JSON text embedded in a script in a document. <html><head><script> document.domain = 'penzance.com'; parent.deliver({ ... JSONtext ... }); </script></head></html> ā€¢ The function deliver is passed the value.
  • 37. JSON in Ajax ā€¢ Dynamic script tag hack. ā€¢ Create a script node. The src url makes the request. ā€¢ The server sends the JSON text embedded in a script. deliver({ ... JSONtext ... }); ā€¢ The function deliver is passed the value. ā€¢ The dynamic script tag hack is insecure.
  • 38. JSONRequest ā€¢ A new facility. ā€¢ Two way data interchange between any page and any server. ā€¢ Exempt from the Same Origin Policy. ā€¢ Campaign to make a standard feature of all browsers.
  • 39. JSONRequest function done(requestNr, value, exception) { ... } var request = JSONRequest.post(url, data, done); var request = JSONRequest.get(url, done); ā€¢ No messing with headers. ā€¢ No cookies. ā€¢ No implied authentication.
  • 40. JSONRequest ā€¢ Requests are transmitted in order. ā€¢ Requests can have timeouts. ā€¢ Requests can be cancelled. ā€¢ Connections are in addition to the browser's ordinary two connections per host. ā€¢ Support for asynchronous, full duplex
  • 41. JSONRequest ā€¢ Tell your favorite browser maker I want JSONRequest! http://www.JSON.org/JSONRequest.html
  • 42. ECMAScript Fourth Ed. ā€¢ New Methods: Object.prototype.toJSONString String.prototype.parseJSON ā€¢ Available now: JSON.org/json.js
  • 43. supplant var template = '<table border="{border}">' + '<tr><th>Last</th><td>{last}</td></tr>' + '<tr><th>First</th><td>{first}</td></tr>' + '</table>'; var data = { "first": "Carl", "last": "Hollywood", "border": 2 }; mydiv.innerHTML = template.supplant(data);
  • 44. supplant String.prototype.supplant = function (o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' ? r : a; } ); };
  • 45. JSONT var rules = { self: '<svg><{closed} stroke="{color}" points="{points}" /></svg>', closed: function (x) {return x ? 'polygon' : 'polyline';}, 'points[*][*]': '{$} ' }; var data = { "color": "blue", "closed": true, "points": [[10,10], [20,10], [20,20], [10,20]] }; jsonT(data, rules) <svg><polygon stroke="blue" points="10 10 20 10 20 20 10 20 " /></svg>
  • 46. http://goessner.net/articles/jsont/ function jsonT(self, rules) { var T = { output: false, init: function () { for (var rule in rules) if (rule.substr(0,4) != "self") rules["self." + rule] = rules[rule]; return this; }, apply: function(expr) { var trf = function (s) { return s.replace(/{([A-Za-z0-9_$.[]'@()]+)}/g, function ($0, $1){ return T.processArg($1, expr); }) }, x = expr.replace(/[[0-9]+]/g, "[*]"), res; if (x in rules) { if (typeof(rules[x]) == "string") res = trf(rules[x]); else if (typeof(rules[x]) == "function") res = trf(rules[x](eval(expr)).toString()); } else res = T.eval(expr); return res; }, processArg: function (arg, parentExpr) { var expand = function (a, e) { return (e = a.replace(/^$/,e)).substr(0, 4) != "self" ? ("self." + e) : e; }, res = ""; T.output = true; if (arg.charAt(0) == "@") res = eval(arg.replace(/@([A-za-z0-9_]+)(([A-Za-z0-9_$.[]']+))/, function($0, $1, $2){ return "rules['self." + $1 + "'](" + expand($2,parentExpr) + ")"; })); else if (arg != "$") res = T.apply(expand(arg, parentExpr)); else res = T.eval(parentExpr); T.output = false; return res; }, eval: function (expr) { var v = eval(expr), res = ""; if (typeof(v) != "undefined") { if (v instanceof Array) { for (var i = 0; i < v.length; i++) if (typeof(v[i]) != "undefined") res += T.apply(expr + "[" + i + "]"); } else if (typeof(v) == "object") { for (var m in v) if (typeof(v[m]) != "undefined") res += T.apply(expr+"."+m); } else if (T.output) res += v; } return res; } }; return T.init().apply("self"); }
  • 47. Some features that make it well-suited for data transfer ā€¢ It's simultaneously human- and machine- readable format; ā€¢ It has support for Unicode, allowing almost any information in any human language to be communicated; ā€¢ The self-documenting format that describes structure and field names as well as specific values; ā€¢ The strict syntax and parsing requirements that allow the necessary parsing algorithms to remain simple, efficient, and consistent; ā€¢ The ability to represent the most general computer science data structures: records, lists and trees.
  • 48. 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...
  • 49. Arguments against JSON ā€¢ JSON Doesn't Have Namespaces. ā€¢ JSON Has No Validator. ā€¢ JSON Is Not Extensible. ā€¢ JSON Is Not XML.
  • 50. JSON Doesn't Have Namespaces ā€¢ Every object is a namespace. Its set of keys is independent of all other objects, even exclusive of nesting. ā€¢ JSON uses context to avoid ambiguity, just as programming languages do.
  • 51. Namespace ā€¢ http://www.w3c.org/TR/REC-xml-names/ ā€¢ In this example, there are three occurrences of the name title within the markup, and the name alone clearly provides insufficient information to allow correct processing by a software module. <section> <title>Book-Signing Event</title> <signing> <author title="Mr" name="Vikram Seth" /> <book title="A Suitable Boy" price="$22.95" /> </signing> <signing> <author title="Dr" name="Oliver Sacks" /> <book title="The Island of the Color-Blind" price="$12.95" /> </signing>
  • 52. Namespace {"section": "title": "Book-Signing Event", "signing": [ { "author": { "title": "Mr", "name": "Vikram Seth" }, "book": { "title": "A Suitable Boy", "price": "$22.95" } }, { "author": { "title": "Dr", "name": "Oliver Sacks" }, "book": { "title": "The Island of the Color-Blind", "price": "$12.95" } } ] }} ā€¢ section.title ā€¢ section.signing[0].author.title ā€¢ section.signing[1].book.title
  • 53. JSON Has No Validator ā€¢ Being well-formed and valid is not the same as being correct and relevant. ā€¢ Ultimately, every application is responsible for validating its inputs. This cannot be delegated. ā€¢ A YAML validator can be used.
  • 54. JSON is Not Extensible ā€¢ It does not need to be. ā€¢ It can represent any non-recurrent data structure as is. ā€¢ JSON is flexible. New fields can be added to existing structures without obsoleting existing programs.
  • 55. JSON Is Not XML ā€¢ objects ā€¢ arrays ā€¢ strings ā€¢ numbers ā€¢ booleans ā€¢ null ā€¢ element ā€¢ attribute ā€¢ attribute string ā€¢ content ā€¢ <![CDATA[ ]]> ā€¢ entities ā€¢ declarations ā€¢ schema ā€¢ stylesheets ā€¢ comments ā€¢ version ā€¢ namespace
  • 56. Data Interchange ā€¢ JSON is a simple, common representation of data. ā€¢ Communication between servers and browser clients. ā€¢ Communication between peers. ā€¢ Language independent data
  • 57. Why the Name? ā€¢ XML is not a good data interchange format, but it is a document standard. ā€¢ Having a standard to refer to eliminates a lot of squabbling.
  • 58. Going Meta ā€¢ By adding one level of meta- encoding, JSON can be made to do the things that JSON can't do. ā€¢ Recurrent and recursive structures. ā€¢ Values beyond the ordinary base values.
  • 59. Going Meta ā€¢ Simply replace the troublesome structures and values with an object which describes them. { "$META$": meta-type, "value": meta-value }
  • 60. Going Meta ā€¢ Possible meta-types: "label" Label a structure for reuse. "ref" Reuse a structure. "class" Associate a class with a structure. "type" Associate a special type, such as Date, with a structure.
  • 61. Browser Innovation ā€¢ During the Browser War, innovation was driven by the browser makers. ā€¢ In the Ajax Age, innovation is being driven by application developers. ā€¢ The browser makers are falling behind.
  • 62. The Mashup Security Problem ā€¢ Mashups are an interesting new way to build applications. ā€¢ Mashups do not work when any of the modules or widgets contains information that is private or represents a connection which is private.
  • 63. The Mashup Security Problem ā€¢ JavaScript and the DOM provide completely inadequate levels of security. ā€¢ Mashups require a security model that provides cooperation under mutual suspicion.
  • 64. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" /> ā€¢ A module is like a restricted iframe. The parent script is not allowed access to the module's window object. The module's script is not allowed access to the parent's window object.
  • 65. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" /> ā€¢ The module node presents a send method which allows for sending a JSON string to the module script. ā€¢ The module node can accept a receive method which allows for receiving a JSON string from the module script.
  • 66. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" /> ā€¢ Inside the module, there is a global send function which allows for sending a JSON string to the outer document's script. ā€¢ Inside the module, you can define a receive method which allows for receiving a JSON string from the outer document's script.
  • 67. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" />
  • 68. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" /> ā€¢ Communiciation is permitted only through cooperating send and receive functions. ā€¢ The module is exempt from the Same Origin Policy.
  • 69. The Mashup Security Solution <module id="NAME" href="URL" style="STYLE" /> ā€¢ Ask your favorite browser maker for the <module> tag.