Discussion List Archives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Anyone want to write a JSON schema for CIF-JSON?

  • Subject: RE: Anyone want to write a JSON schema for CIF-JSON?
  • From: "Bollinger, John C" <John.Bollinger@xxxxxxxxxx>
  • Date: Tue, 13 Jun 2017 18:15:44 +0000
  • Accept-Language: en-US
  • authentication-results: spf=none (sender IP is )smtp.mailfrom=John.Bollinger@STJUDE.ORG;
  • DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=SJCRH.onmicrosoft.com; s=selector1-stjude-org;h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;bh=fSYDE/vgGumiub2lZSsUeQvgV4TAATpshiMYUuPoaaM=;b=LGj+Zwb6DBaKj3dldAoHppYPFVu+QNadjmNYMhfuOkHpx8dcdppzGVJzLfqZ6Wl6u9OGFisejg5vUIuHn5kFCgK0479UJ5vFIjNT6ExuwRg/WyoN4RTTL+EKMBfVhWJ4MXob5sQgALgljmoVykGMPVZkFIMuc814CVadvTYQMT8=
  • In-Reply-To: <CAM+dB2fYaa-cWgSsygz9G5ZgQpCtoZyCdamk0umE0FLnEOPoWQ@mail.gmail.com>
  • References: <CAM+dB2fYaa-cWgSsygz9G5ZgQpCtoZyCdamk0umE0FLnEOPoWQ@mail.gmail.com>
  • spamdiagnosticmetadata: NSPM
  • spamdiagnosticoutput: 1:99

Dear CIF Developers,

 

I’ve got this.  In fact, here’s a first draft:

 

====

 

{

  "$schema":       "http://json-schema.org/draft-06/schema#",

  "id":            "http://www.iucr.org/resources/cif/cif-json.json",

  "description":   "The CIF-JSON top-level object",

  "type":          "object",

  "required":      ["CIF-JSON"],

  "maxProperties": 1,

  "properties":    {

    "CIF-JSON":      {

      "description":              "The CIF-JSON object",

      "type":                     "object",

      "patternProperties":        {

        "^[^A-Z\u0000-\u0020]+$":       {

          "id":                       "#datablock",

          "title":                    "datablock",

          "description":              "An object representing a CIF datablock",

          "type":                     "object",

          "patternProperties":        {

            "^_[^A-Z\u0000-\u0020]+$":      {

              "title":                    "values",

              "description":              "An array of all the values taken by a CIF data item",

              "type":                     "array",

              "minItems":                 1,

              "items":                    {

                "id":                       "#datavalue",

                "title":                    "datavalue",

                "description":              "A CIF data value",

                "anyOf":                    [

                  {

                    "title":                  "string / number",

                    "description":            "A CIF string or numeric value",

                    "type":                   "string"

                  },

                  {

                    "title":                  "null",

                    "description":            "A CIF null value (.)",

                    "type":                   "boolean",

                    "const":                  false

                  },

                  {

                    "title":                  "unknown",

                    "description":            "A CIF unknown value (?)",

                    "type":                   "null"

                  },

                  {

                    "title":                  "list",

                    "description":            "A CIF list value",

                    "type":                   "array",

                    "items":                  { "$ref": "#datavalue" }

                  },

                  {

                    "title":                  "table",

                    "description":            "A CIF table value",

                    "type":                   "object",

                    "additionalProperties":   { "$ref": "#datavalue" }

                  }

                ]

              }

            }

          },

          "properties":           {

            "Frames":               {

              "type":                 "object",

              "patternProperties":    {

                "^[^\u0000-\u0020A-Z]+$":   { "$ref": "#datablock" }

              },

              "additionalProperties": { "not": {} }

            }

          },

          "additionalProperties": { "not": {} }

        }

      },

      "properties": {

        "Metadata":   {

          "description": "provides instance metadata",

          "type":        "object",

          "properties":  {

            "cif-version":    {

              "type":           "string",

              "enum":           ["1.1", "2.0"],

              "description":    "The version of CIF with which the content of this CIF-JSON instance conforms"

            },

            "schema-name":    {

              "type":           "string",

              "const":          "CIF-JSON",

              "default":        "CIF-JSON",

              "description":    "Identifies the JSON format of this instance's content; always 'CIF-JSON' for instances conforming to this schema"

            },

            "schema-version": {

              "type":           "string",

              "pattern":        "(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)",

              "description":    "The version of CIF-JSON to which this instance conforms, in dotted-triplet form; CIF-JSON version numbers are assigned according to semantic versioning principles"

            },

            "schema-uri":     {

              "type":           "string",

              "const":          "http://www.iucr.org/resources/cif/cif-json.json",

              "default":        "http://www.iucr.org/resources/cif/cif-json.json",

              "description":    "A URI (in fact a URL) specifying the location of this schema"

            }

          }

        }

      }

    }

  }

}

 

====

 

Comments:

 

1. This schema is itself valid against the latest draft (#6) of the JSON metaschema, as indeed it declares of itself.  At this time, however, there is not yet a final specification for JSON schema.

 

2. I have specified the schema’s "id" URI as "http://www.iucr.org/resources/cif/cif-json.json", which differs slightly from the schema URI presented in the example accompanying the CIF-JSON specification, and I have furthermore specified in the schema that this revised URI is the one that should be presented in instance documents as the "schema-uri" metadata item (when that is present).

 

3. This schema does not -- and as far as I can determine *cannot* -- express the requirement that various CIF identifier strings be presented in Unicode case-normal form.  I provide a considerably weaker criterion.

 

4. Additionally, this version of the schema does not fully express the CIF character set restrictions.  It could do a little better with a little more work, but because Javascript works with 16-bit code units instead of code _points_, fully expressing the limitations will be trickier and uglier.

 

5. This schema validates the defined Metadata properties, but also allows arbitrary Metadata properties.  This is open to discussion -- it would not be hard for the schema to instead permit only the four specification-defined properties.

 

6. The specification says that the "schema-version" metadata item expresses a version number conforming to semantic versioning.  Accordingly, the schema requires the value of this item to be a dot-delimited triplet of non-negative integers without leading zeroes.  The example CIF accompanying the specification is not valid against the schema in this respect.

 

You can test this schema or your own at https://jsonschemalint.com/

 

 

John

 

--

John C. Bollinger, Ph.D.

Computing and X-Ray Scientist

Department of Structural Biology

St. Jude Children's Research Hospital

John.Bollinger@StJude.org

(901) 595-3166 [office]

www.stjude.org

 

 

 

From: cif-developers [mailto:cif-developers-bounces@iucr.org] On Behalf Of James Hester
Sent: Tuesday, June 13, 2017 2:52 AM
To: Forum for CIF software developers <cif-developers@iucr.org>
Subject: Anyone want to write a JSON schema for CIF-JSON?

 

Dear CIF Developers,

COMCIFS have not so far raised any technical criticisms of our CIF-JSON document, which is a good sign that it will be approved without change once the 6-week comment period expires.  Given that it is unlikely to change, would anyone here like to now volunteer to put together a JSON schema for the standard?

James.


--

T +61 (02) 9717 9907
F +61 (02) 9717 3145
M +61 (04) 0249 4148



Email Disclaimer: www.stjude.org/emaildisclaimer
Consultation Disclaimer: www.stjude.org/consultationdisclaimer
_______________________________________________
cif-developers mailing list
cif-developers@iucr.org
http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers

Reply to: [list | sender only]
International Union of Crystallography

Scientific Union Member of the International Council for Science (admitted 1947). Member of CODATA, the ICSU Committee on Data. Member of ICSTI, the International Council for Scientific and Technical Information. Partner with UNESCO, the United Nations Educational, Scientific and Cultural Organization in the International Year of Crystallography 2014.

ICSU Scientific Freedom Policy

The IUCr observes the basic policy of non-discrimination and affirms the right and freedom of scientists to associate in international scientific activity without regard to such factors as ethnic origin, religion, citizenship, language, political stance, gender, sex or age, in accordance with the Statutes of the International Council for Science.