Subject: [Json] Accidental schema language

From: Tim Bray <[email-masked]>
Date: Thu, 1 Dec 2016 17:55:04 -0800

I had to write a validator for a JSON DSL in an AWS product, and I ended up
sketching in a sort of one-off schema language for the purpose. Of the 27
people on earth who care about such things, a majority are probably on this
mailing list:
https://www.tbray.org/ongoing/When/201x/2016/12/01/J2119-Validator
​
<https://keybase.io/timbray>

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 2 Dec 2016 10:01:18 +0100

> On 2 Dec 2016, at 02:55, Tim Bray <[email-masked]> wrote:
> 
> I had to write a validator for a JSON DSL in an AWS product, and I ended up sketching in a sort of one-off schema language for the purpose. Of the 27 people on earth who care about such things, a majority are probably on this mailing list: https://www.tbray.org/ongoing/When/201x/2016/12/01/J2119-Validator
> ​

FWIW, I wrote a validator for JSON that's based on James Clark's approach using derivatives of patterns. It is part of the Yangson library (Python 3):

https://github.com/CZ-NIC/yangson

The schema language in this case is YANG but it should be really easy to adapt it for DSL.

Lada

> _______________________________________________
> json mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/json

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Phillip Hallam-Baker <[email-masked]>
Date: Fri, 2 Dec 2016 11:22:19 -0500

If people are interested in this stuff, I have a protocol compiler that I
built to construct this:

http://prismproof.org/

The code base actually contains compilers for ASN.1, XML and TLS-Schema
type encodings besides JSON. But right now these are three separate
processors rather than one.

It is all open source under MIT license and can target Windows, Linux or
OSX. The latest version is limited to C# but thats just because the C
backend lags a little.

The way it works is, you write the schema:

https://github.com/hallambaker/Mathematical-Mesh/blob/master/Goedel.Mesh/SchemaMesh.protocol

This is then used to generate the reference section of your Internet Draft:

https://tools.ietf.org/html/draft-hallambaker-mesh-reference-03

The generator also emits code (currently C#)

https://github.com/hallambaker/Mathematical-Mesh/blob/master/Goedel.Mesh/SchemaMesh.cs

You can generate code using a linemode tool and makefile of course. If you
are using Visual Studio, the code generator is integrated into the shell as
a VSIX extension.

The code is currently configured to generate reference code. Which means
that it is intentionally strict in what it accepts and might well become
permissive in what it generates. Reference code should give implementations
a workout.

I have just spent six months cleaning up the code to make it suitable for
production use (with some caveats) The main thing that is missing is that
people should use something like MongoDB as the backend.

The code can also generate examples. These can be emitted as Markdown, HTML
or XML2RFC format. The Markdown format is the one I use.

*Next Steps*

My system meets my current needs. It is not as pretty as it could be but it
is functional and provides a lot more functionality than the YANG tool
chain. My schema language is rather more abstract.

What I would want to do to improve the product is to replace the three
different frontends I use right now with one common frontend. I would also
want that frontend to use a syntax that matches the JSON data model. I
certainly do not want to use JSON. I did sketch out a JSON-A that would be
programmer friendly.