JSON at Work -Overview and Ecosystem        Tom Marrs         Architect
Your ProfileReally?      What else?             How?
What’s The Point?JSON -  much         more ...
JSON Ecosystem               JSON CoreSchema                              Search                              Dev Tools   ...
Our Agenda
We’re Not Covering        :(-RESTXMLSOA
JSON Beginningswww.json.org2001 - Douglas Crockford2006 - IETF - RFC 4627The “x” in AJAXLightweight / simple structures
That was Then ...JSON for Speed   XML for Integration
JSON ValidationStructure   Instance Document [Well-formed]Semantics   Schema [Order, Person]
This is NowJSON for Speed   JSON for Integration
JSON.org
JSON Tutorial - on   the iPhone
JSON Documents{    JSON-Data}
JSON Data           StructuresName/Value (or Key/Value) PairsObjectsArrays
JSON Key/Value Pair    {     "firstName": "John"}
JSON Object    {     "address" : {       "line1" : "555 Main Street",       "city" : "Denver",       "stateOrProvince" : "...
JSON Array"clubs" : [  {     "number" : 677476,     "name" : "Simply Speaking",     "city" : "Aurora",     "district" : 26...
JSON Value Types
Numbers"age": 29"cost": 299.99"temperature": -10.5"speed_of_light": 1.23e11"speed_of_light": 1.23e+11"speed_of_light": 1.2...
Booleans"emailValidated" : true
null{    "address": {        "line1": "555 Main St.",        "line2": null,        "city": "Bailey",        "state": "CO",...
JSON Comments     No
JSON Versions    Never
A Bigger Sample{    "member": {        "firstName": "John",        "lastName": "Smith",        "joined": "2008-12-06",    ...
Google JSON Style      Guide
JSON is Hot!
JSON Tool Runtimes                 JSON Tools                                     iPhone  GUIs                            ...
JSON ValidatorsJSON Validator (Mac)http://www.jsonlint.com
JSONLint.com
JSON BeautifiersFirefox     ChromeJSONView    JSONView            JSON SH
JSON Without a  Beautifier
JSONView
JSON SH
JSON Modeling ToolsJSON Designer              http://                           www.jsonschema.netJSONPad                 ...
JSON Designer - on   the iPhone
Model JSON Doc -   JSONPad
Model JSON Doc -jsoneditoronline.org
JSON and Java -             Jackson    public class Address {    private String line1;    private String city;    private ...
JSON and Java -        Jackson ... Cont’d    import java.io.Writer’import java.io.StringWriter;import org.codehaus.jackson...
Java-based JSON                APIs           API                                     SourceJackson             http://jac...
JSON and HTML5 &      JavaScript - AJAX       $.getJSON(http://example/service/addresses/home/1,     function(data) {     ...
JSON and Ruby on          Rails    class Person  attr_accessor :first_name, :last_name  def initialize(first_name=nil, las...
JSON and Rubyrequire jsonclass Address  attr_accessor :line1, :city, :state_or_province,                :zip_or_postal_cod...
JSON and Ruby  def to_hash    hash = {}    self.instance_variables.each do |var|      hash[var.to_s.delete("@")] = self.in...
JSON and Ruby    addr1 = Address.new(555 Main Street, Denver, CO, 80231, US)puts addr1.to_json # Marshal Address object to...
Ruby-based JSON             APIs       API                             SourceYajl         https://github.com/brianmario/ya...
JSON SchemaDefines JSON document structurehttp://json-schema.org/
When To Use JSON    Schema?When crossing organizational boundaries
When NOT to useJSON Schema?  Get a life - it’s just a website!
JSON Schema             Constructs     Construct                        Descriptiontype             The data type – object...
JSON Schema                 ValidatorsJSON Schema            Language SourceValidatorJSV             JavaScript   https://...
JSON Schema  ExampleGift Registry Document & Schema
JSON Modeling Flow    Model      Create   Generate     JSON      JSON       HTML   Document   Schema    Document
Create JSON Schema  - jsonschema.net
Create JSON Schema      - Orderly
Validate JSON Document against JSON Schema
Generate HTML Documentfrom JSON Schema - Matic
RESTing with JSON
Text Search with       JSONJSONQueryJSONPathJSONiq
Transforming JSONJSONT
Our Agenda
What’s The Point?JSON -  much         more ...
Questions?Tom MarrsArchitectthomasamarrs@comcast.nethttp://www.linkedin.com/in/TomMarrsTwitter: @TomMarrsSkype: t.marrs
JSON ResourcesJSON Spec - http://tools.ietf.org/html/rfc4627JSON.org - http://www.json.orgJSONLint - http://www.jsonlint.c...
JSON ResourcesJSON SH - http://jsonsh.com/JSON Schema Generator - http://jsonschema.netJSON Schema Validator - http://json...
JSON ResourcesJSONQuery - https://github.com/jcrosby/jsonqueryJSONPath - http://goessner.net/articles/JsonPath/JSONiq - ht...
JSON GroupsGoogle - http://groups.google.com/group/json-schemaYahoo! - http://tech.groups.yahoo.com/group/json/
Upcoming SlideShare
Loading in …5
×

Json at work overview and ecosystem-v2.0

1,195 views
1,064 views

Published on

Slides for Tom Marrs BJUG talk on 2/12/2013. See http://boulderjug.org/2013/01/tuesday-february-12-2013-a-night-with-tom-marrs-covering-json-and-rest.html

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,195
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Json at work overview and ecosystem-v2.0

  1. 1. JSON at Work -Overview and Ecosystem Tom Marrs Architect
  2. 2. Your ProfileReally? What else? How?
  3. 3. What’s The Point?JSON - much more ...
  4. 4. JSON Ecosystem JSON CoreSchema Search Dev Tools APIs REST Transform
  5. 5. Our Agenda
  6. 6. We’re Not Covering :(-RESTXMLSOA
  7. 7. JSON Beginningswww.json.org2001 - Douglas Crockford2006 - IETF - RFC 4627The “x” in AJAXLightweight / simple structures
  8. 8. That was Then ...JSON for Speed XML for Integration
  9. 9. JSON ValidationStructure Instance Document [Well-formed]Semantics Schema [Order, Person]
  10. 10. This is NowJSON for Speed JSON for Integration
  11. 11. JSON.org
  12. 12. JSON Tutorial - on the iPhone
  13. 13. JSON Documents{ JSON-Data}
  14. 14. JSON Data StructuresName/Value (or Key/Value) PairsObjectsArrays
  15. 15. JSON Key/Value Pair { "firstName": "John"}
  16. 16. JSON Object { "address" : { "line1" : "555 Main Street", "city" : "Denver", "stateOrProvince" : "CO", "zipOrPostalCode" : "80202", "country" : "USA" }}
  17. 17. JSON Array"clubs" : [ { "number" : 677476, "name" : "Simply Speaking", "city" : "Aurora", "district" : 26 }, { "number" : 999999, "name" : "Wry Toast", "city" : "Denver", "district" : 26 }]
  18. 18. JSON Value Types
  19. 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
  20. 20. Booleans"emailValidated" : true
  21. 21. null{ "address": { "line1": "555 Main St.", "line2": null, "city": "Bailey", "state": "CO", "postalCode": 80909, "country": "USA" }}
  22. 22. JSON Comments No
  23. 23. JSON Versions Never
  24. 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 } }}
  25. 25. Google JSON Style Guide
  26. 26. JSON is Hot!
  27. 27. JSON Tool Runtimes JSON Tools iPhone GUIs Apps Command IDE Line Plugins Browser Online Plugins
  28. 28. JSON ValidatorsJSON Validator (Mac)http://www.jsonlint.com
  29. 29. JSONLint.com
  30. 30. JSON BeautifiersFirefox ChromeJSONView JSONView JSON SH
  31. 31. JSON Without a Beautifier
  32. 32. JSONView
  33. 33. JSON SH
  34. 34. JSON Modeling ToolsJSON Designer http:// www.jsonschema.netJSONPad Overly - Generate Schemahttp://www.jsoneditoronline.org Matic - Generate HTML
  35. 35. JSON Designer - on the iPhone
  36. 36. Model JSON Doc - JSONPad
  37. 37. Model JSON Doc -jsoneditoronline.org
  38. 38. 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 ...
  39. 39. 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);
  40. 40. Java-based JSON APIs API SourceJackson http://jackson.codehaus.org/Google GSON http://code.google.com/p/google-json/SOJO http://sojo.sourceforge.net/org.json (Douglas http://www.json.org/javaCrockford)json-lib http://sourceforge.net/projects/json-lib/json-io http://code.google.com/p/json-iojsontools http://jsontools.berlios.de/jsonbeans http://code.google.com/p/jsonbeans/
  41. 41. 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); });
  42. 42. 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 endendclass 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
  43. 43. JSON and Rubyrequire jsonclass 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
  44. 44. 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
  45. 45. JSON and Ruby addr1 = 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"}ENDaddr2 = Address.newaddr2.from_json!(json_addr) # Unmarshal Address object from JSON string.
  46. 46. Ruby-based JSON APIs API SourceYajl https://github.com/brianmario/yajl-rubyOj https://github.com/ohler55/oj
  47. 47. JSON SchemaDefines JSON document structurehttp://json-schema.org/
  48. 48. When To Use JSON Schema?When crossing organizational boundaries
  49. 49. When NOT to useJSON Schema? Get a life - it’s just a website!
  50. 50. JSON Schema Constructs Construct Descriptiontype The data type – object, array, string, number, etc.required true / falseid Data element id Additional validation properties for a data element (e.g.,properties minimum, maximum, etc.)
  51. 51. JSON Schema ValidatorsJSON Schema Language SourceValidatorJSV JavaScript https://github.com/garycourt/JSVRuby JSON Ruby https://github.com/hoxworth/json-schemaSchema Validatorjson-schema- Java https://github.com/fge/json-schema-validatorvalidatorphp-json-schema PHP https://github.com/hasbridge/php-json-schema(by MIT)JSON.Net .NET http://james.newtonking.com/projects/json-net.aspx
  52. 52. JSON Schema ExampleGift Registry Document & Schema
  53. 53. JSON Modeling Flow Model Create Generate JSON JSON HTML Document Schema Document
  54. 54. Create JSON Schema - jsonschema.net
  55. 55. Create JSON Schema - Orderly
  56. 56. Validate JSON Document against JSON Schema
  57. 57. Generate HTML Documentfrom JSON Schema - Matic
  58. 58. RESTing with JSON
  59. 59. Text Search with JSONJSONQueryJSONPathJSONiq
  60. 60. Transforming JSONJSONT
  61. 61. Our Agenda
  62. 62. What’s The Point?JSON - much more ...
  63. 63. Questions?Tom MarrsArchitectthomasamarrs@comcast.nethttp://www.linkedin.com/in/TomMarrsTwitter: @TomMarrsSkype: t.marrs
  64. 64. JSON ResourcesJSON Spec - http://tools.ietf.org/html/rfc4627JSON.org - http://www.json.orgJSONLint - http://www.jsonlint.comJSON Editor Online - http://jsoneditoronline.org/
  65. 65. JSON ResourcesJSON SH - http://jsonsh.com/JSON Schema Generator - http://jsonschema.netJSON Schema Validator - http://json-schema-validator.herokuapp.com/JSON Schema Spec - http://tools.ietf.org/html/draft-zyp-json-schema-03Google JSON Style Guide - http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml
  66. 66. JSON ResourcesJSONQuery - https://github.com/jcrosby/jsonqueryJSONPath - http://goessner.net/articles/JsonPath/JSONiq - http://www.jsoniq.org/JSONT - http://goessner.net/articles/jsont/
  67. 67. JSON GroupsGoogle - http://groups.google.com/group/json-schemaYahoo! - http://tech.groups.yahoo.com/group/json/

×