A Language for Rules Describing JSON Content

The information below is for an old version of the document
Document Type Active Internet-Draft (individual)
Author Andrew Newton 
Last updated 2014-08-28
Stream (None)
Intended RFC status (None)
Formats pdf htmlized (tools) htmlized bibtex
Stream Stream state (No stream defined)
Consensus Boilerplate Unknown
RFC Editor Note (None)
IESG IESG state I-D Exists
Telechat date
Responsible AD (None)
Send notices to (None)
Network Working Group                                          A. Newton
Internet-Draft                                                      ARIN
Intended status: Standards Track                         August 28, 2014
Expires: March 1, 2015

              A Language for Rules Describing JSON Content


   This document describes a language useful for documenting the
   expected content of JSON structures found in specifications using

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on March 1, 2015.

Copyright Notice

   Copyright (c) 2014 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Newton                    Expires March 1, 2015                 [Page 1]
Internet-Draft             JSON Content Rules                August 2014

1.  Introduction

   The goal of this document is to provide a way to document the
   expected content of data expressed in JSON [RFC4627] format.  That
   is, the primary purpose of this document is to specify a means for
   one person to communicate with another person the expected nature of
   a JSON data structure in a method more concise than prose.  The
   programmatic validation of a JSON data structure against content
   rules is a lesser goal of this document, though such a practice is
   useful in both the writing of specifications and the communications
   of programs.

   Unlike JSON Schema, this language is not JSON though the syntax
   described here is "JSON-like" (a comparison with JSON Schema can be
   found in Appendix A and a "real world" example can be found in
   Appendix B).  A specialized syntax is used to reduce the tedium in
   reading and writing rules as the complexity describing allowable
   content is often more involved than most of the actual content.
   Figure 2 is an example of this language describing the JSON of
   Figure 1.

   Example JSON lifted from RFC 4627

          "precision": "zip",
          "Latitude":  37.7668,
          "Longitude": -122.3959,
          "Address":   "",
          "City":      "SAN FRANCISCO",
          "State":     "CA",
          "Zip":       "94107",
          "Country":   "US"
          "precision": "zip",
          "Latitude":  37.371991,
          "Longitude": -122.026020,
          "Address":   "",
          "City":      "SUNNYVALE",
          "State":     "CA",
          "Zip":       "94085",
          "Country":   "US"

                                 Figure 1

Newton                    Expires March 1, 2015                 [Page 2]
Internet-Draft             JSON Content Rules                August 2014

   Rules describing Figure 1

   root [
           "precision" : string,
           "Latitude" : float,
           "Longitude" : float,
           "Address" : string,
           "City" : string,
           "State" : string,
           "Zip" : string,
           "Country" : string

                                 Figure 2

   The JSON Content Rules are of five types:

   o  value rules

   o  member rules

   o  array rules

   o  object rules

   o  group rules

   Each rule has two components, a rule name and a rule definition.
   Anywhere in a rule definition where a rule name is allowed, another
   rule definition may be used.

   This is an example of a value rule:

      v1 : integer 0..3

   It specifies a rule named "v1" that has a definition of ": integer
   0..3" (value rule definitions begin with a ':' character).  This
   defines values of type "v1" to be integers in the range 0 to 3
   (minimum value of 0, maximum value of 3).  Value rules can define the
   limits of JSON values, such as stating that numbers must fall into a
Show full document text