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:
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:
-
-
obj = {name:”foo”, child: {”name” : “bar”}};
-
obj.child.parent = obj;
-
and shows:
JAVASCRIPT:
-
-
// fixups scheme
-
-
{”result”:{”name”:”foo”, “child”: {”name” : “bar”}},
-
“fixups”:[[[”child”,”parent”],[]]]}
-
-
// id referencing
-
-
{”name”:”foo”, “id”:”1″, “child”: {”name” : “bar”,”parent”:{”id”:”1″}}}
-
-
//or
-
-
{”name”:”foo”, “$id”:”1″, “child”: {”name” : “bar”,”parent”:{”$idref”:”1″}}}
-
-
// path referencing
-
-
{”name”:”foo”, “child”: {”name” : “bar”,”parent”:{”id”:”$”}}}
-
-
// or
-
-
{”name”:”foo”, “child”: {”name” : “bar”,”parent”:”$jref:this”}}
-
Kris has proposed a schema definition which would look a bit like this:
JAVASCRIPT:
-
-
{
-
“name”: {”type”:”string”,
-
“required”:true},
-
“age” : {”type”:”number”,
-
“maximum”:125}
-
}
-
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