shake, with fries

by Zach Carter

Posts tagged jsonschema

Dec31

Orderly.js Web Version

javascript json jsonschema orderly | comments

I've commited a minified, dependency-free version* of orderly.js for use on the web. It introduces an orderly object, with parse and compile methods.

Usage is straight forward:

<script src="orderly.js"></script>
<script>
    var orderlySource = "array {};";

    var jsonSchemaSource = orderly.compile(orderlySource);

    var jsonSchemaObject = orderly.parse(orderlySource);
</script>

Edit: View the online demo here.

*Excpet for a JSON stringifier, to account for browsers that don't include native JSON yet.

Dec27

Orderly.js: Orderly to JSONSchema Compiler

javascript commonjs jison orderly jsonschema json compiler parser | comments

Orderly is a textual format for describing JSON. Orderly can be compiled into JSONSchema. It is designed to be easy to read and write.

I decided to give Jison a real-world spin by creating an Orderly to JSONSchema compiler for JavaScript. After about three days, interspersed with lots of eating and family vists, I have a working implementation, which I call Orderly.js.

Usage

var orderly = require("orderly");

var orderlySource = "array {};";

var jsonSchemaSource = orderly.compile(orderlySource);

var jsonSchemaObject = orderly.parse(orderlySource);

print(JSON.stringify(jsonSchemaObject));

An API for building parsers

I must say, Jison made this really simple. I don't consider myself a speedy coder in the slightest, probably the opposite, but I was able to crank this out in a (holiday) weekend. Jison takes care of the hard parts of parsing, all you need is a working grammar* and the appropriate hooks. I'll be writing more on Jison shortly.

*This can be non-trivial, though if the language you are parsing already specifies a grammar, as was the case with Orderly, you're set!