Json at work overview and ecosystem-v2.0
-
Upload
boulder-java-users-group -
Category
Documents
-
view
792 -
download
1
description
Transcript of Json at work overview and ecosystem-v2.0
![Page 1: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/1.jpg)
JSON at Work -Overview and Ecosystem
Tom MarrsArchitect
![Page 2: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/2.jpg)
Your ProfileReally?
What else?
How?
![Page 3: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/3.jpg)
What’s The Point?
JSON -
much
more ...
![Page 4: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/4.jpg)
JSON Ecosystem
Schema Search
APIs
Transform REST
Dev Tools
JSON Core
![Page 5: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/5.jpg)
Our Agenda
![Page 6: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/6.jpg)
We’re Not Covering :(-
REST
XML
SOA
![Page 7: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/7.jpg)
JSON Beginnings
www.json.org
2001 - Douglas Crockford
2006 - IETF - RFC 4627
The “x” in AJAX
Lightweight / simple structures
![Page 8: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/8.jpg)
That was Then ...JSON for Speed XML for Integration
![Page 9: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/9.jpg)
JSON Validation
Structure Instance Document [Well-formed]
Semantics Schema [Order, Person]
![Page 10: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/10.jpg)
This is NowJSON for Speed JSON for Integration
![Page 11: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/11.jpg)
JSON.org
![Page 12: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/12.jpg)
JSON Tutorial - on the iPhone
![Page 13: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/13.jpg)
JSON Documents
{ JSON-Data}
![Page 14: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/14.jpg)
JSON Data Structures
Name/Value (or Key/Value) Pairs
Objects
Arrays
![Page 15: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/15.jpg)
JSON Key/Value Pair
{ "firstName": "John"}
![Page 16: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/16.jpg)
JSON Object{
"address" : { "line1" : "555 Main Street", "city" : "Denver", "stateOrProvince" : "CO", "zipOrPostalCode" : "80202", "country" : "USA" }}
![Page 17: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/17.jpg)
JSON Array"clubs" : [ { "number" : 677476, "name" : "Simply Speaking", "city" : "Aurora", "district" : 26 }, { "number" : 999999, "name" : "Wry Toast", "city" : "Denver", "district" : 26 }]
![Page 18: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/18.jpg)
JSON Value Types
![Page 19: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/19.jpg)
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
![Page 20: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/20.jpg)
Booleans
"emailValidated" : true
![Page 21: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/21.jpg)
null
{ "address": { "line1": "555 Main St.", "line2": null, "city": "Bailey", "state": "CO", "postalCode": 80909, "country": "USA" }}
![Page 22: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/22.jpg)
JSON Comments
No
![Page 23: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/23.jpg)
JSON Versions
Never
![Page 24: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/24.jpg)
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": "[email protected]", "homePhone": "303-555-1212", "cellPhone": "720-555-1212", "workPhone": "970-555-1212" }, "club": { "number": 677476, "name": "Simply Speaking", "city": "Aurora", "district": 26 } }}
![Page 25: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/25.jpg)
Google JSON Style Guide
![Page 26: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/26.jpg)
JSON is Hot!
![Page 27: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/27.jpg)
JSON Tool Runtimes
GUIs iPhone Apps
IDE Plugins
Browser Plugins
Online
Command Line
JSON Tools
![Page 28: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/28.jpg)
JSON Validators
JSON Validator (Mac)
http://www.jsonlint.com
![Page 29: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/29.jpg)
JSONLint.com
![Page 30: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/30.jpg)
JSON BeautifiersFirefox
JSONView
Chrome
JSONView
JSON SH
![Page 31: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/31.jpg)
JSON Without a Beautifier
![Page 32: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/32.jpg)
JSONView
![Page 33: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/33.jpg)
JSON SH
![Page 34: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/34.jpg)
JSON Modeling ToolsJSON Designer
JSONPad
http://www.jsoneditoronline.org
http://www.jsonschema.net
Overly - Generate Schema
Matic - Generate HTML
![Page 35: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/35.jpg)
JSON Designer - on the iPhone
![Page 36: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/36.jpg)
Model JSON Doc -JSONPad
![Page 37: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/37.jpg)
Model JSON Doc -jsoneditoronline.org
![Page 38: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/38.jpg)
JSON and Java - Jackson
public class Address { private String line1; private String city; private String stateOrProvince; private String zipOrPostalCode; private String country;
public Address() {} public String getLine1() { return line1; } public void setLine1(line1) { this.line1 = line1; } // Remaining getters and setters ...}
Address addrOut = new Address();// Call setters to populate addrOut ...
![Page 39: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/39.jpg)
JSON and Java - Jackson ... Cont’d
import java.io.Writer’import java.io.StringWriter;import org.codehaus.jackson.map.ObjectMapper;
ObjectMapper mapper = new ObjectMapper(); // Reuse this.
// Marshal Address object to JSON String.Writer writer = new StringWriter();mapper.writeValue(writer, addrOut);System.out.println(writer.toString());
// Unmarshal Address object from JSON String.String addrJsonStr = "{" + "\"address\" : {" + "\"line1\" : \"555 Main Street\"," + "\"city\" : \"Denver\"," "\"stateOrProvince\" : \"CO\"," "\"zipOrPostalCode\" : \"80202\"," + "\"country\" : \"USA\"" + "}" +"}";
Address addrIn = mapper.readValue(addrJsonStr, Address.class);
![Page 40: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/40.jpg)
Java-based JSON APIs
API Source
Jackson http://jackson.codehaus.org/
Google GSON http://code.google.com/p/google-json/
SOJO http://sojo.sourceforge.net/
org.json (Douglas Crockford)
http://www.json.org/java
json-lib http://sourceforge.net/projects/json-lib/
json-io http://code.google.com/p/json-io
jsontools http://jsontools.berlios.de/
jsonbeans http://code.google.com/p/jsonbeans/
![Page 41: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/41.jpg)
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); });
![Page 42: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/42.jpg)
JSON and Ruby on Rails
class Person attr_accessor :first_name, :last_name
def initialize(first_name=nil, last_name=nil) @first_name = first_name @last_name = last_name endend
class MyController < ApplicationController def index person = Person.new('John', 'Doe') respond_to do |format| format.html # index.html.erb format.json { render :json => person} end endend
![Page 43: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/43.jpg)
JSON and Ruby
require 'json'
class Address
attr_accessor :line1, :city, :state_or_province, :zip_or_postal_code, :country def initialize(line1=nil, city=nil, state_or_province=nil, zip_or_postal_code=nil, country=nil) @line1 = line1 @city = city @state_or_province = state_or_province @zip_or_postal_code = zip_or_postal_code @country = country end
![Page 44: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/44.jpg)
JSON and Ruby
def to_hash hash = {} self.instance_variables.each do |var| hash[var.to_s.delete("@")] = self.instance_variable_get(var) end hash end def to_json to_hash.to_json end
def from_json!(str) JSON.load(str).each do |var, val| self.instance_variable_set("@#{var}", val) end endend
![Page 45: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/45.jpg)
JSON and Rubyaddr1 = Address.new('555 Main Street', 'Denver', 'CO', '80231', 'US')
puts addr1.to_json # Marshal Address object to JSON string.
# Outputs the following …( "line1": "555 Main Street", "city": "Denver", "state_or_province": "CO", "zip_or_postal_code": "80231","country":"US" }
json_addr = <<END{ "line1" : "999 Broadway", "city" : "Anytown", "state_or_province" : "CA", "zip_or_postal_code" : "90210", "country" : "USA"}END
addr2 = Address.newaddr2.from_json!(json_addr) # Unmarshal Address object from JSON string.
![Page 46: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/46.jpg)
Ruby-based JSON APIs
API Source
Yajl https://github.com/brianmario/yajl-ruby
Oj https://github.com/ohler55/oj
![Page 47: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/47.jpg)
JSON Schema
Defines JSON document structure
http://json-schema.org/
![Page 48: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/48.jpg)
When To Use JSON Schema?
When crossing organizational boundaries
![Page 49: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/49.jpg)
When NOT to use JSON Schema?
Get a life - it’s just a website!
![Page 50: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/50.jpg)
JSON Schema Constructs
Construct Description
type The data type – object, array, string, number, etc.
required true / false
id Data element id
properties Additional validation properties for a data element (e.g., minimum, maximum, etc.)
![Page 51: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/51.jpg)
JSON Schema Validators
JSON Schema Validator Language Source
JSV JavaScript https://github.com/garycourt/JSV
Ruby JSON Schema Validator
Ruby https://github.com/hoxworth/json-schema
json-schema-validator
Java https://github.com/fge/json-schema-validator
php-json-schema (by MIT)
PHP https://github.com/hasbridge/php-json-schema
JSON.Net .NET http://james.newtonking.com/projects/json-net.aspx
![Page 52: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/52.jpg)
JSON Schema Example
Gift Registry Document & Schema
![Page 53: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/53.jpg)
JSON Modeling Flow
ModelJSON
Document
CreateJSON
Schema
GenerateHTML
Document
![Page 54: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/54.jpg)
Create JSON Schema - jsonschema.net
![Page 55: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/55.jpg)
Create JSON Schema - Orderly
![Page 56: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/56.jpg)
Validate JSON Document against JSON Schema
![Page 57: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/57.jpg)
Generate HTML Document from JSON Schema - Matic
![Page 58: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/58.jpg)
RESTing with JSON
![Page 59: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/59.jpg)
Text Search with JSON
JSONQuery
JSONPath
JSONiq
![Page 60: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/60.jpg)
Transforming JSON
JSONT
![Page 61: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/61.jpg)
Our Agenda
![Page 62: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/62.jpg)
What’s The Point?
JSON -
much
more ...
![Page 63: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/63.jpg)
Questions?Tom Marrs
Architect
http://www.linkedin.com/in/TomMarrs
Twitter: @TomMarrs
Skype: t.marrs
![Page 64: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/64.jpg)
JSON ResourcesJSON Spec - http://tools.ietf.org/html/rfc4627
JSON.org - http://www.json.org
JSONLint - http://www.jsonlint.com
JSON Editor Online - http://jsoneditoronline.org/
![Page 65: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/65.jpg)
JSON ResourcesJSON 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
![Page 66: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/66.jpg)
JSON ResourcesJSONQuery - https://github.com/jcrosby/jsonquery
JSONPath - http://goessner.net/articles/JsonPath/
JSONiq - http://www.jsoniq.org/
JSONT - http://goessner.net/articles/jsont/
![Page 67: Json at work overview and ecosystem-v2.0](https://reader033.fdocuments.in/reader033/viewer/2022061218/54b6f5b44a7959b67a8b458f/html5/thumbnails/67.jpg)
JSON Groups
Google - http://groups.google.com/group/json-schema
Yahoo! - http://tech.groups.yahoo.com/group/json/