JSON News: JSON Schema and JSON Referencing

Written by on October 11th, 2007 in Ajax News.

Kris Zyp has been plugging away on a couple of interesting JSON topics:

JSON Referencing Schemes

There has been a lot of discussion about handling referencing schemes, so Kris has gotten the various ideas and summarized them.

He takes the following object call:

JAVASCRIPT:

  1.  
  2. obj = {name:”foo”, child: {”name” : “bar”}};
  3. obj.child.parent = obj;
  4.  

and shows:

JAVASCRIPT:

  1.  
  2. // fixups scheme
  3.  
  4. {”result”:{”name”:”foo”, “child”: {”name” : “bar”}},
  5.   “fixups”:[[[”child”,”parent”],[]]]}
  6.  
  7. // id referencing
  8.  
  9. {”name”:”foo”, “id”:”1″, “child”: {”name” : “bar”,”parent”:{”id”:”1″}}}
  10.  
  11. //or
  12.  
  13. {”name”:”foo”, “$id”:”1″, “child”: {”name” : “bar”,”parent”:{”$idref”:”1″}}}
  14.  
  15. // path referencing
  16.  
  17. {”name”:”foo”, “child”: {”name” : “bar”,”parent”:{”id”:”$”}}}
  18.  
  19. // or
  20.  
  21. {”name”:”foo”, “child”: {”name” : “bar”,”parent”:”$jref:this”}}
  22.  

JSON Schema Proposal

Kris has proposed a schema definition which would look a bit like this:

JAVASCRIPT:

  1.  
  2. {
  3.   “name”: {”type”:”string”,
  4.     “required”:true},
  5.   “age” : {”type”:”number”,
  6.     “maximum”:125}
  7. }
  8.  

There are some questions and thoughts about it and he is looking for community feedback on all of this stuff!

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/168474585/json-news-json-schema-and-json-referencing

Leave a Reply

You must be logged in to post a comment.



Site Navigation