JSON Referencing and Schema

  • 9,417 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • In slide 23, the json schema interface is just a proposal right? I mean, there is no support for methods validation from any json schema validation tool, right?
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
9,417
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
204
Comments
1
Likes
12

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Persistent Computing on the Web with JSON Schema and Referencing
    • Kris Zyp
  • 2. Overview
    • JSON Referencing
    • JSON Schema
    • The possiblities...
  • 3. JSON + Hyperlinks = JSON Referencing
  • 4. JSON Referencing
    • Cyclic
    • Multiple references
    • Cross-message references
    • Cross-site references
    http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/
  • 5. JSON Referencing (ID Based)‏
    • {
      • “ name”:”Kris Zyp”,
      • “ id”:”kriszyp”, “children”:[{“id”:”jennikazyp”,“name”:”Jennika Zyp”}],
      • “ spouse”:{
        • “ name”:”Nicole Zyp”, “spouse”:{“$ref”:”kriszyp”},
        • “ children”:[{“$ref”:”jennikazyp”}]
      • }
    • }
  • 6. JSON Referencing (Path Based)‏
    • {
      • “ name”:”Kris Zyp”, “children”:[{“name”:”Jennika Zyp”}],
      • “ spouse”:{
        • “ name”:”Nicole Zyp”, “spouse”:{“$ref”:”#”},
        • “ children”:{“$ref”:”#.children”}
      • }
    • }
  • 7. JSON Referencing (ID + Path)‏
    • {
      • “ name”:”Kris Zyp”,
      • “ id”:”kriszyp”, “children”:[{“name”:”Jennika Zyp”}],
      • “ friends”:[{“$ref”:”jesse#.spouse”}]
    • }
  • 8. JSON + Schema = JSON Schema
  • 9. JSON Schema
    • schema:
    • {"description":"A person",
    • "type":"object",
    • "properties":
    • {"name": {"type":"string"},
    • "age" : {"type":"integer",
    • "maximum":125}}
    • }
    • instance:
    • {“name”:”Kris”,
    • “ age”:30}
  • 10. JSON Schema
    • Schema:
    • {"description":"A person",
    • "type":"object",
    • "properties":
    • {"name": {"type":"string"},
    • "age" : {"type":"integer",
    • "maximum":125, “optional”:true}, “friends”: {“type”:”array”, “items”:{“type”:”object”}} }
    • }
    • instance:
    • {“name”:”Kris”,
    • “ friends”:[{“name”:”Nikki”}]
    • }
  • 11. JSON Schema
    • Schema:
    • {“type”:”array”, “items”:[{“type”:”string”},{“type”:”number”}] }
    • instance:
    • [“foo”,44]
  • 12. JSON Schema
    • Schema:
    • {"description":"A person",
    • "type":["object",”string”]
    • }
    • instance:
    • “ foo”
    • instance:
    • {“prop”:3}
  • 13. JSON Schema
    • Schema:
    • {"description":"A person",
    • "type":["object",”string”]
    • }
    • instance:
    • “ foo”
    • instance:
    • {“prop”:3}
  • 14. JSON Schema
    • schema:
    • {"description":"A person",
    • "type":"object",
    • "properties":
    • {"name": {"type":"string"},
    • "gender" : {"type":"string",
          • "enum”:[“male”,”female”]}},
    • “ additionalProperties”:false
    • }
    • instance:
    • {“name”:”Kris”,
    • “ gender”:”male”}
  • 15. What can we do with these?
  • 16. JSON Schema + JSON Referencing
    • {"description":"A Social Person", “id”:”socialperson”,
    • "type":"object",
    • "properties":
    • {"name": {"type":"string"},
    • "age" : {
        • "type":"integer",
    • "maximum":125
      • },
      • "friends" : {
        • “ type” : ”array”,
        • “ items” : {“$ref”:”socialperson”}
      • }
    • },
    • “ extends”:{“$ref”:”person”}
    • }
  • 17. JSON Referencing + REST
    • Lazy loading - Generic clients can auto-load objects as necessary
    • Object identification can be used for saving state changes
    http://blog.medryx.org/2008/07/24/jsonreststore-overview/
  • 18. JSON Referencing + REST
    • GET /Person/3
    • {
    • “ name”:”Kris”,
    • “ friends”:[
      • {“$ref”:”4”},
      • {“$ref”:”5”}
    • ]
    • }
  • 19. JSON Referencing + JSON-RPC
    • POST /person/kriszyp
    • {
      • “ method”:”addFriend”,
      • “ id”:”1”,
      • “ params”:[{“$ref”:”jessesmith”}]
    • }
  • 20. Applying data definitions to code
  • 21. JSON Schema + Typed Code
  • 22. JSON Schema Interfaces
  • 23. JSON Schema Interface
    • {"description":"A person",
    • "type":"object",
    • "properties":
    • {"name": {"type":"string"} }, “methods”:{ “getName”:{“returns”:{“type”:”string”}, “params”:[]}, “setName”:{“params”:[{“type”:”string”}]}, }
    • }
  • 24. Cross-site Referencing
    • {
      • “ name”:”Kris Zyp”,
      • “ id”:”kriszyp”,
      • “ friends”:[
        • {“$ref”:” http://thezyps.com/person/nikki ”},
        • {“$ref”:” http://social.com/user/33 ”}
      • ]
    • }
  • 25. Cross-site Typing
  • 26. Mobile code (run anywhere)‏
    • Code can run anywhere
      • Server JavaScript Environment
      • Browser JavaScript Environment
    • Consistent persisted data structures across environments
  • 27. Connecting and structuring data for the future JSON Schema and JSON Referencing
  • 28.