SlideShare a Scribd company logo
Advanced JSON   Persistence Mapping, RPCs,  Cross-Domain and More. Kris Zyp [email_address] www.xucia.com www.json.com
Overview Specifications - JSON JSONT JSONPath JSON Referencing JSON Schema JSON-RPC JSPON JSON-P Tools CrossSafe JSPON Browser Persevere
JSON Overview/History JSON born from JavaScript object and array initializer syntax {“property”:”value”, “number”:2, “boolean”:true, “oddNumbers”:[1,3,5]} XML vs JSON Strengths of each
About JSON JSON = { “size” : “compact”, “readable” : true, “purposes” :  [“simple data structures”, ”object serialization”], “simple” : true, “easily parsed” : true }
XML… <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <xml xmlns:ajson=&quot;http://www.xucia.com/ page/Advanced_JSON&quot; > <size>bigger</size> <readable type=“boolean” expectation=“consumer defines booleans the same way I do”>true</readable> <purpose ambiguity=“Is this an array?”>Give semantic meaning to documents</purpose> <derived_from>SGML</derived_from> <legacy_uses>many</legacy_uses> </xml>
Interoperability Minimizing cost of communication. JSON has a lot of flexibility. Conventions don’t matter as much when we write the client & server, but will with mashups JSON Definitions help us to interoperate without having to create or understand custom JSON usage. Analogous to RSS, SOAP, and XHTML in the XML world.
Cross Domain JSON XHR Same Origin Policy Script tags can access cross site scripts Dynamic Script Tag Insertion How to know when it loads? How to know what was returned? Is JSON even a valid script?
JSONP http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/ Defines a parameter for defining a prefix for JSON returned in a script www.jsonsource.com/?callback=done done({“name”:”my json object”}) Yahoo, Flickr provide this for their webservices Unsecure used alone!
CrossSafe How to access cross-domain data securely? Proxy – Secure, but slower and more work. Dynamic Script Tags – Faster, more direct, but insecure, cross domain has full access to your JS environment. Alternate technologies – Flash, signed applets CrossSafe – Fast, direct access that is secure. Implements JSONRequest Specification Implements Subspace Approach Uses Dynamic Script Tag insertion in nested iframes with domain containment for sandboxing
CrossSafe Must use hostname.domain.com and make webservice.domain.com accessible Servers must support JSONP or other callback parameter JSONRequest.get(“http://www.yahoo.com/..”, function(id, value) { … } Defers to native implementation when available Show Demo: http://www.xucia.com/page/CrossSafe
JSONT http://goessner.net/articles/jsont/ Data: {  &quot;link&quot; : { &quot;uri&quot; : &quot;http://company.com&quot; ,  &quot;title&quot; : &quot;company homepage&quot;  }}  Transformation: {  &quot;link&quot; :  &quot;<a href=\&quot;{link.uri}\&quot;>{link.title}</a>&quot;  }  Result:  <a href= &quot;http://company.com&quot; >company homepage</a>
Referencing Circular References Me = {“name”:”Kris Zyp”, “spouse” : {“name”:”Nikki Zyp”}} MyWife = Me.spouse; MyWife.spouse = Me; Multiples References to single objects list = [{“name”:”first”,”child”:{“name”:”the child”}}, {“name”:”second”}] list[1].child = list[0].child;
JSON Referencing www.json.com Scope Intramessage Circular References Multiple References Intermessage Cross-Domain references Reference Methods Path  - ref: “$.prop[4]” ID  - ref: “111”
JSON Referencing (Intramessage) www.json.com Reference Methods Conventions – in string, fixups, in object Path – use $ for JSON root (per JSONPath) [{“child”:{“name”:”the child”}}, {“child”:{“$ref”:”$[0].child”}}] ID [{“child”:{“id”:”1”,“name”:”the child”}}, {“child”:{“$ref”:”1”}}] Combine – {“$ref”:”1.name”}
JSON Referencing www.json.com Intermessage – must use ID referencing Intermessage {“id”:”1”,”name”:”first”,   “ child”:{“id”:”3”,“name”:”the child”}} {“id”:”2”,”name”:”second”,   “ child”:{“$ref”:”3”}} Remote References {“id”:”2”,”name”:”second”,   “ child”:{“$ref”:”http://www.json.com/jsonObject”}}  URL rules Use the standard HTML rules for relative URLs in context GET /users/2 {“id”:”2”,”name”:”john”,”group”:{“$ref”:”../groups/1”}}
Identification Circular References Me = {“id”:”kris”,  “ name”:”Kris Zyp”, “ spouse”:{“id”:”nikki”, “ name”:”Nikki Zyp”: “ spouse”:{“$ref”:”kris”}}} Library available on json.com
JSPON www.jspon.org Background… RESTful approach for interaction and interoperability with persistent data Most JSON is used to describe persisted data Deals with complex data structures, modifications, and more JSPON = REST + JSON + Relative URLs for ids and references
JSPON  Over   HTTP Every id has an implicit (or explicit) URL using the standard relative URL approach References to ids can be used for unloaded values (lazy loading) REST service POST to an id/url to append to an object PUT to an id/url to change an object GET to an id/url to get an object DELETE to an id/url to delete an object
Identification GET http://mydomain.com/objects/myObj {“id”:”myObj”  -> http://mydomain.com/objects/myObj “ name”:”my object”, “ moreInfo”: {“$ref”:”largeObject”}, ->  http://mydomain.com/object/myObj “ crossSiteRef”: {“$ref”:”http://yourdomain.com/yourObj”}, ->  http://yourdomain.com/yourObj “ user”: {“$ref”:”../users/1”}, ->  http:// mydomain.com/object/myObj } Partial Graph Transfer/Lazy Loading Object Modification Cross Domain Object Trees
Persevere Server JSON Server Object database server Interaction through REST commands with JSON Queries through JSONPath JSPON id approach Supports JSONP JSON-RPC method calls Demo distributed calls later JSON Schema support
Persevere Server Exposes multiple data sources as JSON (JSPON): Internal OO Database SQL Databases (MySQL, HSQL, etc) XML files Data Centric Security Avoids application logic centric security Modular server – can be used with other servers
JSPON Object Browser Capable of browsing, modifying, and observing structural and access rules of data sources. Demo at: http://www.xucia.com/browser.html?id=dyna%2F100788
JSONPath XPath for JSON Influenced by XPath and E4X syntax, and traditional C/Java/JS property access syntax Examples: $.store.book[0].title -> What you think $..author -> Recursive search authors $.book[:4]    first four books $.book[?(@.price<10)] -> books under 10
JSON-RPC http://json-rpc.org/ Request method  - A string containing the name of the method to be invoked.  params  - An array of objects to pass as arguments to the method.  id  - The request id. This can be of any type. It is used to match the response with the request that it is replying to.
JSON-RPC Response result  - The object that was returned by the invoked method. This must be null in case there was an error invoking the method.  error  - An error object if there was an error invoking the method. It must be null if there was no error.  id  - This must be the same id as the request it is responding to.
JSON-RPC Example { &quot;method&quot;: &quot;echo&quot;, &quot;params&quot;: [&quot;Hello JSON-RPC&quot;], &quot;id&quot;: 1} { &quot;result&quot;: &quot;Hello JSON-RPC&quot;, &quot;error&quot;: null, &quot;id&quot;: 1}
Persevere Server Client/Server JavaScript Persistent Object Mapping Rhino Environment
JSON Schema http://www.json.com/json-schema-proposal/ Contract about valid data Influenced by XML Schema, Kwalify, RelaxNG, and ES4 Analogous to Classes in OO Languages or DTDs/Schemas in XML Defines requirements for JSON properties and other property attributes Uses Validation - data integrity Documentation Interaction UI generation (forms and code) Can be used on the client and server Compact Implementation
JSON Schema Example {“name”:{ “type”:”string”, “required”:true, “nullable”:false, “ length”:25, “description”:”Name of the person”}, “ age”:{ “type”:”number”, “minimum”:0, “maximum”:125} }
JSON Schema Example {“address”:{ “type”:{“street”:{“type”:”string”}, “state”:{“type”:”string”}}, “ description”:”Where they live”}, “ born”:{“type”:[“number”,”string”]} }
JSON Schema Example {“name”:”Kris Zyp” “ age”:30, “ spouse”:{“id”:”nikki”}, “ schema”:{“id”:”person”, “ name”:{“type”:”string”}, “ age”:{“type”:”number”}, “ spouse”:{“type”:{“$ref”:”person”}} // recursive def }}
Persevere JS Client Persistent object mapping with REST web services Orthogonal Persistence and Lazy Loading Capabilities Implements JSON-RPC Method Calls Implements Persistent JavaScript API: http://www.persistentjavascript.org Implements JSPON  With Persevere Server – End to end JS
Example Usage of Persevere var result = pjs.load(“data or query id”); var object = result[1]; var value = object.prop; object.prop = “new value”; result.push({name:”new object/row”}) Array.remove(result,object); // or splice
What Did We Not Have to Write? doAjax… (break up into multiple slides) Request controller Do sql… API to learn… Almost zero, majority of operations are standard JavaScript
Persevere JS Client Capabilities Compared to Jester – Jester is perfect for RoR Robust and scalable Lazy loading Automatic and Explicit Transactions Designed for optimistic locking/merging Auto save/Orthogonality Integration with Strands for threading/continuations Bi-directional dynamic object and structure creation and modification
Demo Demonstration of CRUD application with customer database. Fits well with other JavaScript libraries
Persevere Persisted Applications Functions/Methods can be stored in the persisted object stores Applications can exist as persistent object graphs. Persevere server implements Persistent JavaScript on the server. Distributed Computing capable with other JSPON/RPC implementators. Transparent remote calls
Persisted Application & Distributed Computing Demonstration Customers Demo Find Primes Demo Reverse Ajax Inheritance
Thank you for your time See the presentation and links to projects at: www.xucia.com/page/AdvancedJSON Xucia Incorporation www.xucia.com www.json.com email:  [email_address]   Kris Zyp 503-806-1841

More Related Content

PPT
JavaScript Object Notation (JSON)
PPTX
Introduction to HTML5 and CSS3 (revised)
PDF
Javascript
PPT
XML Schema
PDF
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
PPT
Introduction to Javascript
PPTX
Mongo DB Presentation
JavaScript Object Notation (JSON)
Introduction to HTML5 and CSS3 (revised)
Javascript
XML Schema
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Introduction to Javascript
Mongo DB Presentation

What's hot (20)

PPTX
Css selectors
PPT
Javascript
PPTX
Oracle REST Data Services Best Practices/ Overview
ODP
Introduction to Swagger
PDF
Introduction to elasticsearch
PDF
JSON-LD: JSON for the Social Web
PDF
Cross-domain requests with CORS
PDF
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
PPT
JavaScript & Dom Manipulation
PPTX
Benchmarking NGINX for Accuracy and Results
PDF
1. Arquitecturas y Herramientas de Programación
PPTX
The Basics of MongoDB
PPTX
JavaScript Basic
PDF
[211] 네이버 검색과 데이터마이닝
PDF
JavaScript Programming
PPT
OpenSearch
PDF
Webinar: Working with Graph Data in MongoDB
PDF
Handle Large Messages In Apache Kafka
PDF
JavaScript - Chapter 8 - Objects
PDF
Contextual Computing - Knowledge Graphs & Web of Entities
Css selectors
Javascript
Oracle REST Data Services Best Practices/ Overview
Introduction to Swagger
Introduction to elasticsearch
JSON-LD: JSON for the Social Web
Cross-domain requests with CORS
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
JavaScript & Dom Manipulation
Benchmarking NGINX for Accuracy and Results
1. Arquitecturas y Herramientas de Programación
The Basics of MongoDB
JavaScript Basic
[211] 네이버 검색과 데이터마이닝
JavaScript Programming
OpenSearch
Webinar: Working with Graph Data in MongoDB
Handle Large Messages In Apache Kafka
JavaScript - Chapter 8 - Objects
Contextual Computing - Knowledge Graphs & Web of Entities
Ad

Viewers also liked (20)

ODP
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
PPTX
JSON and REST
PPTX
KEY
JSON-LD and MongoDB
KEY
JSON-LD: JSON for Linked Data
PPTX
JSON: The Basics
PDF
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
PPTX
Design Beautiful REST + JSON APIs
PPTX
Starting with JSON Path Expressions in Oracle 12.1.0.2
PPTX
Running Away from JSON (or what I learned building the OneNote API)
KEY
The Developer Experience
PPT
RESTful JSON web databases
PDF
JSON-RPC Proxy Generation with PHP 5
PPTX
Мероприятия как инструмент работы с молодыми специалистами и продвижения брен...
DOC
Mars
PDF
Uncle Ben's Recipe Video Contest Flyer
PPT
Seattle SeaHawks
PPTX
CouchDB Day NYC 2017: JSON Documents
PPT
Mars Business report
PPT
Sara's m&m slideshow
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
JSON and REST
JSON-LD and MongoDB
JSON-LD: JSON for Linked Data
JSON: The Basics
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
Design Beautiful REST + JSON APIs
Starting with JSON Path Expressions in Oracle 12.1.0.2
Running Away from JSON (or what I learned building the OneNote API)
The Developer Experience
RESTful JSON web databases
JSON-RPC Proxy Generation with PHP 5
Мероприятия как инструмент работы с молодыми специалистами и продвижения брен...
Mars
Uncle Ben's Recipe Video Contest Flyer
Seattle SeaHawks
CouchDB Day NYC 2017: JSON Documents
Mars Business report
Sara's m&m slideshow
Ad

Similar to Advanced Json (20)

PPT
Java Script Based Client Server Webapps 2
PDF
Json at work overview and ecosystem-v2.0
PDF
LF_APIStrat17_Embracing JSON Schema
PDF
Json
PPT
json.ppt download for free for college project
PDF
JSON Fuzzing: New approach to old problems
PPT
J s-o-n-120219575328402-3
PDF
Basics of JSON (JavaScript Object Notation) with examples
PDF
Hands on JSON
PDF
Json the-x-in-ajax1588
PDF
Introduction to JSON
PPTX
PPTX
JSON & AJAX.pptx
PPT
Javascript2839
PPT
PPTX
Introduction to JSON & AJAX
PPTX
Pythonlearn-13-WebServices.pptx
PPTX
Android and REST
Java Script Based Client Server Webapps 2
Json at work overview and ecosystem-v2.0
LF_APIStrat17_Embracing JSON Schema
Json
json.ppt download for free for college project
JSON Fuzzing: New approach to old problems
J s-o-n-120219575328402-3
Basics of JSON (JavaScript Object Notation) with examples
Hands on JSON
Json the-x-in-ajax1588
Introduction to JSON
JSON & AJAX.pptx
Javascript2839
Introduction to JSON & AJAX
Pythonlearn-13-WebServices.pptx
Android and REST

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
KodekX | Application Modernization Development
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
KodekX | Application Modernization Development
MIND Revenue Release Quarter 2 2025 Press Release
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf

Advanced Json

  • 1. Advanced JSON Persistence Mapping, RPCs, Cross-Domain and More. Kris Zyp [email_address] www.xucia.com www.json.com
  • 2. Overview Specifications - JSON JSONT JSONPath JSON Referencing JSON Schema JSON-RPC JSPON JSON-P Tools CrossSafe JSPON Browser Persevere
  • 3. JSON Overview/History JSON born from JavaScript object and array initializer syntax {“property”:”value”, “number”:2, “boolean”:true, “oddNumbers”:[1,3,5]} XML vs JSON Strengths of each
  • 4. About JSON JSON = { “size” : “compact”, “readable” : true, “purposes” : [“simple data structures”, ”object serialization”], “simple” : true, “easily parsed” : true }
  • 5. XML… <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <xml xmlns:ajson=&quot;http://www.xucia.com/ page/Advanced_JSON&quot; > <size>bigger</size> <readable type=“boolean” expectation=“consumer defines booleans the same way I do”>true</readable> <purpose ambiguity=“Is this an array?”>Give semantic meaning to documents</purpose> <derived_from>SGML</derived_from> <legacy_uses>many</legacy_uses> </xml>
  • 6. Interoperability Minimizing cost of communication. JSON has a lot of flexibility. Conventions don’t matter as much when we write the client & server, but will with mashups JSON Definitions help us to interoperate without having to create or understand custom JSON usage. Analogous to RSS, SOAP, and XHTML in the XML world.
  • 7. Cross Domain JSON XHR Same Origin Policy Script tags can access cross site scripts Dynamic Script Tag Insertion How to know when it loads? How to know what was returned? Is JSON even a valid script?
  • 8. JSONP http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/ Defines a parameter for defining a prefix for JSON returned in a script www.jsonsource.com/?callback=done done({“name”:”my json object”}) Yahoo, Flickr provide this for their webservices Unsecure used alone!
  • 9. CrossSafe How to access cross-domain data securely? Proxy – Secure, but slower and more work. Dynamic Script Tags – Faster, more direct, but insecure, cross domain has full access to your JS environment. Alternate technologies – Flash, signed applets CrossSafe – Fast, direct access that is secure. Implements JSONRequest Specification Implements Subspace Approach Uses Dynamic Script Tag insertion in nested iframes with domain containment for sandboxing
  • 10. CrossSafe Must use hostname.domain.com and make webservice.domain.com accessible Servers must support JSONP or other callback parameter JSONRequest.get(“http://www.yahoo.com/..”, function(id, value) { … } Defers to native implementation when available Show Demo: http://www.xucia.com/page/CrossSafe
  • 11. JSONT http://goessner.net/articles/jsont/ Data: { &quot;link&quot; : { &quot;uri&quot; : &quot;http://company.com&quot; , &quot;title&quot; : &quot;company homepage&quot; }} Transformation: { &quot;link&quot; : &quot;<a href=\&quot;{link.uri}\&quot;>{link.title}</a>&quot; } Result: <a href= &quot;http://company.com&quot; >company homepage</a>
  • 12. Referencing Circular References Me = {“name”:”Kris Zyp”, “spouse” : {“name”:”Nikki Zyp”}} MyWife = Me.spouse; MyWife.spouse = Me; Multiples References to single objects list = [{“name”:”first”,”child”:{“name”:”the child”}}, {“name”:”second”}] list[1].child = list[0].child;
  • 13. JSON Referencing www.json.com Scope Intramessage Circular References Multiple References Intermessage Cross-Domain references Reference Methods Path - ref: “$.prop[4]” ID - ref: “111”
  • 14. JSON Referencing (Intramessage) www.json.com Reference Methods Conventions – in string, fixups, in object Path – use $ for JSON root (per JSONPath) [{“child”:{“name”:”the child”}}, {“child”:{“$ref”:”$[0].child”}}] ID [{“child”:{“id”:”1”,“name”:”the child”}}, {“child”:{“$ref”:”1”}}] Combine – {“$ref”:”1.name”}
  • 15. JSON Referencing www.json.com Intermessage – must use ID referencing Intermessage {“id”:”1”,”name”:”first”, “ child”:{“id”:”3”,“name”:”the child”}} {“id”:”2”,”name”:”second”, “ child”:{“$ref”:”3”}} Remote References {“id”:”2”,”name”:”second”, “ child”:{“$ref”:”http://www.json.com/jsonObject”}} URL rules Use the standard HTML rules for relative URLs in context GET /users/2 {“id”:”2”,”name”:”john”,”group”:{“$ref”:”../groups/1”}}
  • 16. Identification Circular References Me = {“id”:”kris”, “ name”:”Kris Zyp”, “ spouse”:{“id”:”nikki”, “ name”:”Nikki Zyp”: “ spouse”:{“$ref”:”kris”}}} Library available on json.com
  • 17. JSPON www.jspon.org Background… RESTful approach for interaction and interoperability with persistent data Most JSON is used to describe persisted data Deals with complex data structures, modifications, and more JSPON = REST + JSON + Relative URLs for ids and references
  • 18. JSPON Over HTTP Every id has an implicit (or explicit) URL using the standard relative URL approach References to ids can be used for unloaded values (lazy loading) REST service POST to an id/url to append to an object PUT to an id/url to change an object GET to an id/url to get an object DELETE to an id/url to delete an object
  • 19. Identification GET http://mydomain.com/objects/myObj {“id”:”myObj” -> http://mydomain.com/objects/myObj “ name”:”my object”, “ moreInfo”: {“$ref”:”largeObject”}, -> http://mydomain.com/object/myObj “ crossSiteRef”: {“$ref”:”http://yourdomain.com/yourObj”}, -> http://yourdomain.com/yourObj “ user”: {“$ref”:”../users/1”}, -> http:// mydomain.com/object/myObj } Partial Graph Transfer/Lazy Loading Object Modification Cross Domain Object Trees
  • 20. Persevere Server JSON Server Object database server Interaction through REST commands with JSON Queries through JSONPath JSPON id approach Supports JSONP JSON-RPC method calls Demo distributed calls later JSON Schema support
  • 21. Persevere Server Exposes multiple data sources as JSON (JSPON): Internal OO Database SQL Databases (MySQL, HSQL, etc) XML files Data Centric Security Avoids application logic centric security Modular server – can be used with other servers
  • 22. JSPON Object Browser Capable of browsing, modifying, and observing structural and access rules of data sources. Demo at: http://www.xucia.com/browser.html?id=dyna%2F100788
  • 23. JSONPath XPath for JSON Influenced by XPath and E4X syntax, and traditional C/Java/JS property access syntax Examples: $.store.book[0].title -> What you think $..author -> Recursive search authors $.book[:4]  first four books $.book[?(@.price<10)] -> books under 10
  • 24. JSON-RPC http://json-rpc.org/ Request method - A string containing the name of the method to be invoked. params - An array of objects to pass as arguments to the method. id - The request id. This can be of any type. It is used to match the response with the request that it is replying to.
  • 25. JSON-RPC Response result - The object that was returned by the invoked method. This must be null in case there was an error invoking the method. error - An error object if there was an error invoking the method. It must be null if there was no error. id - This must be the same id as the request it is responding to.
  • 26. JSON-RPC Example { &quot;method&quot;: &quot;echo&quot;, &quot;params&quot;: [&quot;Hello JSON-RPC&quot;], &quot;id&quot;: 1} { &quot;result&quot;: &quot;Hello JSON-RPC&quot;, &quot;error&quot;: null, &quot;id&quot;: 1}
  • 27. Persevere Server Client/Server JavaScript Persistent Object Mapping Rhino Environment
  • 28. JSON Schema http://www.json.com/json-schema-proposal/ Contract about valid data Influenced by XML Schema, Kwalify, RelaxNG, and ES4 Analogous to Classes in OO Languages or DTDs/Schemas in XML Defines requirements for JSON properties and other property attributes Uses Validation - data integrity Documentation Interaction UI generation (forms and code) Can be used on the client and server Compact Implementation
  • 29. JSON Schema Example {“name”:{ “type”:”string”, “required”:true, “nullable”:false, “ length”:25, “description”:”Name of the person”}, “ age”:{ “type”:”number”, “minimum”:0, “maximum”:125} }
  • 30. JSON Schema Example {“address”:{ “type”:{“street”:{“type”:”string”}, “state”:{“type”:”string”}}, “ description”:”Where they live”}, “ born”:{“type”:[“number”,”string”]} }
  • 31. JSON Schema Example {“name”:”Kris Zyp” “ age”:30, “ spouse”:{“id”:”nikki”}, “ schema”:{“id”:”person”, “ name”:{“type”:”string”}, “ age”:{“type”:”number”}, “ spouse”:{“type”:{“$ref”:”person”}} // recursive def }}
  • 32. Persevere JS Client Persistent object mapping with REST web services Orthogonal Persistence and Lazy Loading Capabilities Implements JSON-RPC Method Calls Implements Persistent JavaScript API: http://www.persistentjavascript.org Implements JSPON With Persevere Server – End to end JS
  • 33. Example Usage of Persevere var result = pjs.load(“data or query id”); var object = result[1]; var value = object.prop; object.prop = “new value”; result.push({name:”new object/row”}) Array.remove(result,object); // or splice
  • 34. What Did We Not Have to Write? doAjax… (break up into multiple slides) Request controller Do sql… API to learn… Almost zero, majority of operations are standard JavaScript
  • 35. Persevere JS Client Capabilities Compared to Jester – Jester is perfect for RoR Robust and scalable Lazy loading Automatic and Explicit Transactions Designed for optimistic locking/merging Auto save/Orthogonality Integration with Strands for threading/continuations Bi-directional dynamic object and structure creation and modification
  • 36. Demo Demonstration of CRUD application with customer database. Fits well with other JavaScript libraries
  • 37. Persevere Persisted Applications Functions/Methods can be stored in the persisted object stores Applications can exist as persistent object graphs. Persevere server implements Persistent JavaScript on the server. Distributed Computing capable with other JSPON/RPC implementators. Transparent remote calls
  • 38. Persisted Application & Distributed Computing Demonstration Customers Demo Find Primes Demo Reverse Ajax Inheritance
  • 39. Thank you for your time See the presentation and links to projects at: www.xucia.com/page/AdvancedJSON Xucia Incorporation www.xucia.com www.json.com email: [email_address] Kris Zyp 503-806-1841