JSON

Developing the next generation of open data interchange

« PreviousNext »

JSON Schema Proposal (RFC)

2 October 2007

I have been working on creating a JSON Schema proposal, and I wanted to get feedback on  the specification so far. JSON Schema is a specification for a JSON-based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how it can be modified, much like what XML Schema provides for XML. JSON Schema is intended to provide validation, documentation, and interaction control of JSON data.

Please see the specification proposal here. Once we get some agreement on the direction of specification, I will try to make a reference implementation available.

Here are some questions I wanted to discuss regarding the proposal:

I wonder if different name choices should be used for properties:

I have defined properties default, and prototype, which are technically different concepts, but they both can effectively provide similiar effect (provide a starting value). I wonder if for simplicity if one of these should should be dropped.

Another issue is name conflicts. If an instance object has a property called sealed, the schema object would have no way of defining it because it conflicts with one of it’s properties. One solution could be introduce a namespacing approach for JSON. This might be particularly important since the ES4 will introduce namespaces into JavaScript and there is no mechanism devised for how to handle this.

Posted in JSON Schema | Trackback | del.icio.us | Top Of Page

    7 Responses to “JSON Schema Proposal (RFC)”

  1. Ric Johnson Says:

    The links to the RFC are broken

  2. Kris Zyp Says:

    OK, should be fixed now. Sorry for my wordpress incompetence.

  3. geoff Says:

    It seems to me that eventually any attempt to create a new schema-mechanism is going to rediscover many of the things that have been hashed out in other schemas, like XML schema….namespacing, regular expressions for validation, data typing, choice groups, etc., etc.

    Also, it’s a common problem to have an existing XML schema, and an associated web services that produces XML, but you’d like to have a JSON “binding” (a JSON version of the I/O to the web service).

    Therefore, the approach I have taken has simply been to use Annotation and Documentation elements in my existing XML schemas, which instruct software on how to produce a JSON representation of the data.

    This allows me to have a single definition of data content (the XML schema) but multiple over-the-wire representations of the data.

  4. Kris Zyp Says:

    One of the expressed purposes of the JSON Schema is to have JSON-based schema, that is the schema should exist in JSON. Also, as stated in the proposal, JSON Schema uses the concepts from XML Schema. This is not an attempt to reinvent the wheel, but JSON simply does not have a one-to-one correspondence with XML (namespaces, attributes, mixed data, and so on), and using a schema that is intended for a different language and very complicated is difficult and clumsy. It is fine to use annotations in XML schemas to express JSON representations, but I believe that JSON consumers should be able to refer to a schema that is in the same language (JSON) and built for that language.

  5. Chris O. Says:

    Reinventing the wheel isn’t necessary. JSON should replace XML, but only in data structure. Allow the value-seperator character to be in objects’ key collections–and requiring that keys ALWAYS be quoted:

    {
    “version”: 1.0,
    “encoding”: “UTF-8″, {
    “rdf:RDF”: {
    “xmlns:rdf”: “http://www.w3.org/1999/02/22-rdf-syntax-ns#”,
    “xmlns:rdfs”: “http://www.w3.org/2000/01/rdf-schema#”,
    “xmlns:w2x”: “http://www.web2express.org/ns/1.0/”,
    “channel”: {
    “rdf:about”: “http://www.web2express.org/ufeed/datafeed/rdf/AN715164/Product”,
    “title”: “Product Feed”,
    “link”: “http://www.web2express.org/ufeed/viewfeed?acc=AN715164&cat=Product”,
    “w2x:startTime”: “2007-09-03 02:52:48″
    }
    }
    }
    }

  6. Kris Zyp Says:

    Chris, your example is not even a schema, it is an RSS fragment, how is that connected to a JSON Schema? We don’t want to reinvent the wheel, but we don’t want to just blindly bring in complicated unnatural concepts to the JSON Schema. JSON isn’t just a different syntax than XML, it is conceptually different data structure, and maintaining the simplicity of JSON with schemas is very important.

  7. anonymous Says:

    Why not use XML to define schema for JSON? that seems to combine the best things of each

Leave a Reply