Recently I proposed orderly, an idea for a small microlanguage on top of JSONSchema — something easier to read and write.
There’s been some great
feedback
which I find encouraging. In response I’ve set up
orderly-json.org and started a project on
github which will host the
specification, the reference implementation, and all of the contents
of the json-orderly.org
site.
recent changes
Given initial feedback and a bunch more thought about orderly, theres a couple significant early changes that have taken place.
repetition quantifiers get curly, enumeration values go square
in v-1 (yes, negative one) the following code would have specified an integer property with a range of allowable values:
integer foo[0,10];
And the following, would specify an integer property @bar@ with allowable values 0-10.
integer bar[0,10]
uh. oops? We need a way outta this mess. The current v0 specification moves range specification to after the type (suggested by Toby A Inkster, and changes syntax from square braces to curly braces. We’re re-using “repetition quantifiers” from regular expressions here, and while the analogy isn’t perfect, nor is the square brace analogy where storage allocation is the expectation. Enumeration values, in turn, have more exclusive access to square braces, which is nice because this is the JSON representation of arrays. Here’s an example of a property @weight@ which must be in a certain numeric range:
number{0.02, 0.98} weight;
While possible values are represented after the type using JSON style array notation:
string os ["osx", "win32", "linux", "freebsd"];
An enumeration property on JSONSchema is nothing more than an array of potential values. And a more beautiful seque into the next point, I couldn’t have engineered..
Orderly syntax is a superset of JSON
JSON is wholly contained within the syntax of orderly, and the reason for this is simple. Because orderly must be able to represent default values of any object of arbitrary complexity. The bad news is this means it’s going to be a little more work to parse, but the good news is there’s plenty of precedent to leverages (numerical representation, etc).
What’s next?
As the language starts to firm up, I’ve resolved to take popular APIs and try to describe them with orderly, see how far we get. Today’s target is the BrowserPlus JSON WSAPI that returns a list of available services, here’s a subset of the data we’re trying to describe:
[ { "name": "PublishSubscribe", "versionString": "1.0.0", "os": "ind", "size": 5114, "documentation": "A cross document message service that allows JavaScript to send and receive messages between web pages within one or more browsers (cross document + cross process).", "CoreletType": "dependent", "CoreletRequires": { "Name": "RubyInterpreter", "Version": "4", "Minversion": "4.2.5" } }, { "name": "Uploader", "versionString": "3.2.6", "os": "osx", "size": 279378, "documentation": "This service lets you upload files faster and easier than before.", "CoreletType": "standalone", "CoreletAPIVersion": 4 }, { "name": "RubyInterpreter", "versionString": "4.2.6", "os": "osx", "size": 1691095, "documentation": "Allows other services to be written in Ruby.", "CoreletType": "provider", "CoreletAPIVersion": 4 } ]
And here’s concocted orderly to describe this data:
# A schema describing the data returned from the BrowserPlus services # API at http://browserplus.yahoo.com/api/v3/corelets/osx array { object { string name; string versionString; string os [ "ind", "osx", "win32" ]; integer size; string documentation; string CoreletType [ "standalone", "dependent", "provider" ]; # if CoreletType is "standalone" or "provider", then # CoreletAPIVersion must be present integer CoreletAPIVersion ?; # if CoreletType is "dependent", then CoreletRequires must be present object { string Name; string Version; string Minversion; } CoreletRequires ?; }; };
Not bad. Some semantics of this ad-hoc WSAPI cannot be captured in orderly nor it seems the JSONSchema underneath, but I think I’m ok with that. You?
lloyd