A Language for Rules Describing JSON Content
draft-newton-json-content-rules-03

The information below is for an old version of the document
Document Type Active Internet-Draft (individual)
Author Andrew Newton 
Last updated 2014-10-15
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                        October 14, 2014
Expires: April 17, 2015

              A Language for Rules Describing JSON Content
                   draft-newton-json-content-rules-03

Abstract

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

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 April 17, 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 April 17, 2015                 [Page 1]
Internet-Draft             JSON Content Rules               October 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 April 17, 2015                 [Page 2]
Internet-Draft             JSON Content Rules               October 2014

   Rules describing Figure 1

   root [
       2*2{
           "precision" : string,
           "Latitude" : float,
           "Longitude" : float,
           "Address" : string,
           "City" : string,
           "State" : string,
           "Zip" : string,
           "Country" : string
       }
   ]

                                 Figure 2

   Depending on need and desired style, an alternate mapping can be used
   where certain symbols are substituted for words.

   Rules describing Figure 1 with an alternate syntax

   root ARRAY
       2*2 OBJECT
               MEMBER "precision" VALUE string AND
               MEMBER "Latitude" VALUE float AND
               MEMBER "Longitude" VALUE float AND
               MEMBER "Address" VALUE string AND
               MEMBER "City" VALUE string AND
               MEMBER "State" VALUE string AND
               MEMBER "Zip" VALUE string AND
               MEMBER "Country" VALUE string
       END_OBJECT
   END_ARRAY

                                 Figure 3

   The JSON Content Rules are of five types:
Show full document text