Wednesday, December 23rd, 2009

Orderly JSON

Category: JavaScript, JSON, Library

<p>Lloyd Hilaiel of Yahoo! BrowserPlus fame, has a little holiday gift for us. He has created a simple library called Orderly that “is a textual format for describing JSON. Orderly can be compiled into JSONSchema. It is designed to be easy to read and write.”

He shares:

A little bit of orderly…

javascript
< view plain text >
  1. object {
  2.   string name;
  3.   string description?;
  4.   string homepage /^http:/;
  5.   integer {1500,3000} invented;
  6. }*;

…describes a little bit of JSON…

javascript
< view plain text >
  1. {
  2.   "name": "orderly",
  3.   "description": "A schema language for JSON",
  4.   "homepage": "http://orderly-json.org",
  5.   "invented": 2009
  6. }

…and compiles into JSONSchema.

javascript
< view plain text >
  1. {
  2.   "type": "object",
  3.   "properties": {
  4.     "name": {
  5.       "type": "string"
  6.     },
  7.     "description": {
  8.       "type": "string",
  9.       "optional": true
  10.     },
  11.     "homepage": {
  12.       "type": "string",
  13.       "pattern": "^http:"
  14.     },
  15.     "invented": {
  16.       "type": "integer",
  17.       "minimum": 1500,
  18.       "maximum": 3000
  19.     }
  20.   },
  21.   "additionalProperties": true
  22. }

Go into detail on Orderly in the documentation or try the
interactive by-directional Orderly – JSONSchema area.

Related Content:

Posted by Dion Almaer at 6:34 am
10 Comments

+++--
3 rating from 31 votes

10 Comments »

Comments feed TrackBack URI

looks cool, but what happens after the year 3000?!

Comment by bluevoodoo1 — December 23, 2009

So it’s basically the old ascii plist format?

Comment by d4rkl1gh7 — December 23, 2009

I just hope by the year 3000, we have something better than HTML + JS, heh.

Comment by jonhartmann — December 23, 2009

what happens after the year 3000?!

The Jonas brothers arrive, and everyone is doing fine, but they live under water.

Comment by peters438 — December 23, 2009

Why in the `homepage` is the rule-set after the name, but in the following line the rule-set is before the name?

Comment by tj111 — December 23, 2009

It should be noted, that this is not done in JavaScript. Its a C code thingy.

Comment by Aimos — December 23, 2009

@bluevoodoo1 by the year 3000 everything there is to invent will already be thought up?

@d4rkl1gh7 nice analogy. It’s also been likened to RelaxNG’s compact syntax (which was a latent influencer). I hope that everyone can compare it to something, then go guess the syntax.

@Aimos An initial primary motivation of orderly was to be able to document web apis in a clearer and more rigorous way (currently most people just post example output). From the likes of it, it sounds like you feel even that should be left to an example instance document (in which case the reader intuits the “schema” based on this single instance) or with jsonschema. If you feel this way, well, you might have sunk my battleship. I’ll have to think up a different holiday present for you. Do you like legos?

Comment by lloydhilaiel — December 23, 2009

PLEASE let JSON as simple as it is. If you need to specify type, comment, etc. and if you need to validate with a schema you can use XML.
There is no need to make a thing so simple and clear to something than already exist (and that nobody want to use).

Comment by fpiat — December 24, 2009

I couldn’t agree more with fpiat – why cock up something that works so well due to its minimalistic flexibility?

Comment by sixtyseconds — December 27, 2009

@fpiat & sixtyseconds,
Erm… You do realize this is optional right? Not an addition to the JSON spec… Ergo, JSON stays simple…
.
This is just a tool for programmers that need to build well tested, well formed, robust and safe applications.

Comment by BenGerrissen — December 28, 2009

Leave a comment

You must be logged in to post a comment.