Json at work overview and ecosystem-v2.11. JSON at Work -
Overview and Ecosystem
Tom Marrs
Architect
Tuesday, February 19, 13
2. Your Profile
Really?
What else?
How?
Tuesday, February 19, 13
8. JSON Beginnings
www.json.org
2001 - Douglas Crockford
2006 - IETF - RFC 4627
The “x” in AJAX
Lightweight / simple structures
Tuesday, February 19, 13
9. That was Then ...
JSON for Speed XML for Integration
Tuesday, February 19, 13
10. JSON Validation
Structure Instance Document [Well-formed]
Semantics Schema [Order, Person]
Tuesday, February 19, 13
11. This is Now
JSON for Speed JSON for Integration
Tuesday, February 19, 13
13. JSON Documents
{
"thisIs": "My First JSON Doc"
}
Tuesday, February 19, 13
14. JSON Data
Structures
Name/Value (or Key/Value) Pairs
Objects
Arrays
Tuesday, February 19, 13
16. JSON Object
{
"address" : {
"line1" : "555 Main Street",
"city" : "Denver",
"stateOrProvince" : "CO",
"zipOrPostalCode" : "80202",
"country" : "USA"
}
}
Tuesday, February 19, 13
17. JSON Array
"clubs" : [
{
"number" : 677476,
"name" : "Simply Speaking",
"city" : "Aurora",
"district" : 26
},
{
"number" : 999999,
"name" : "Wry Toast",
"city" : "Denver",
"district" : 26
}
]
Tuesday, February 19, 13
19. Numbers
"age": 29
"cost": 299.99
"temperature": -10.5
"speed_of_light": 1.23e11
"speed_of_light": 1.23e+11
"speed_of_light": 1.23E11
"speed_of_light": 1.23E+11
Tuesday, February 19, 13
20. JSON Boolean
{
"emailValidated": true
}
Tuesday, February 19, 13
21. null
{
"address": {
"line1": "555 Main St.",
"line2": null,
"city": "Bailey",
"state": "CO",
"postalCode": 80909,
"country": "USA"
}
}
Tuesday, February 19, 13
24. A Bigger Sample
{
"member": {
"firstName": "John",
"lastName": "Smith",
"joined": "2008-12-06",
"language": "US English",
"reason": "To improve my public speaking skills. To take over the world.",
"address": {
"line1": "555 Main St.",
"city": "Bailey",
"state": "CO",
"postalCode": 80909,
"country": "USA"
},
"contact": {
"email": "john.smith@acme.com",
"homePhone": "303-555-1212",
"cellPhone": "720-555-1212",
"workPhone": "970-555-1212"
},
"club": {
"number": 677476,
"name": "Simply Speaking",
"city": "Aurora",
"district": 26
}
}
}
Tuesday, February 19, 13
26. Property Names
{
"somePropertyIdentifier": "some value"
}
Tuesday, February 19, 13
27. Date Property Values
- RFC 3399
{
"dateJoined": "2007-11-06T16:34:41.000Z"
}
Tuesday, February 19, 13
32. JSON Validators
JSON Validator (Mac)
http://www.jsonlint.com
Tuesday, February 19, 13
34. JSON Beautifiers
Firefox Chrome
JSONView JSONView
JSON SH
Tuesday, February 19, 13
38. JSON Modeling Tools
JSON Designer http://
www.jsonschema.net
JSONPad
Overly - Generate
Schema
http://
www.jsoneditoronline.org
Matic - Generate HTML
Tuesday, February 19, 13
44. JSON and HTML5 &
JavaScript - AJAX
$.getJSON('http://example/service/addresses/home/1',
function(data) {
var address = JSON.parse(data);
console.log("Address Line 1 = " + address.line1);
}
);
Tuesday, February 19, 13
47. JSON Schema
Defines JSON document structure
http://json-schema.org/
Tuesday, February 19, 13
48. When To Use JSON
Schema?
When crossing organizational boundaries
Tuesday, February 19, 13
49. When NOT to use
JSON Schema?
Get a life - it’s just a website!
Tuesday, February 19, 13
50. JSON Schema
Constructs
Construct Description
type The data type – object, array, string, number, etc.
required true / false
id Data element id
Additional validation properties for a data element (e.g.,
properties
minimum, maximum, etc.)
Tuesday, February 19, 13
51. JSON Schema
Validators
JSON Schema
Language Source
Validator
JSV JavaScript https://github.com/garycourt/JSV
Ruby JSON
Ruby https://github.com/hoxworth/json-schema
Schema Validator
json-schema-
Java https://github.com/fge/json-schema-validator
validator
php-json-schema
PHP https://github.com/hasbridge/php-json-schema
(by MIT)
JSON.Net .NET http://james.newtonking.com/projects/json-net.aspx
Tuesday, February 19, 13
52. JSON Schema
Example
Gift Registry Document & Schema
Tuesday, February 19, 13
64. Questions?
Tom Marrs
Architect
thomasamarrs@comcast.net
http://www.linkedin.com/in/
TomMarrs
Twitter: @TomMarrs
Skype: t.marrs
Tuesday, February 19, 13
65. JSON Resources
JSON Spec - http://tools.ietf.org/html/rfc4627
JSON.org - http://www.json.org
JSONLint - http://www.jsonlint.com
JSON Editor Online - http://jsoneditoronline.org/
Tuesday, February 19, 13
66. JSON Resources
JSON SH - http://jsonsh.com/
JSON Schema Generator - http://jsonschema.net
JSON Schema Validator - http://json-schema-validator.herokuapp.com/
JSON Schema Spec - http://tools.ietf.org/html/draft-zyp-json-schema-03
Google JSON Style Guide - http://google-styleguide.googlecode.com/svn/trunk/
jsoncstyleguide.xml
Tuesday, February 19, 13
67. JSON Resources
JSONQuery - https://github.com/jcrosby/jsonquery
JSONPath - http://goessner.net/articles/JsonPath/
JSONiq - http://www.jsoniq.org/
JSONT - http://goessner.net/articles/jsont/
Tuesday, February 19, 13
68. JSON Groups
Google - http://groups.google.com/group/json-schema
Yahoo! - http://tech.groups.yahoo.com/group/json/
Tuesday, February 19, 13