0

Passing data between web services often means passing JSON data. A standard for evaluating JSON data is under development at json-schema.org. I would like to incorporate Esri JSON data in my schema definition. Has anyone developed json-schema definitions for Esri JSON or GeoJSON? I am new to json-schema. These definition files work at jsonlint.com However, I'm not sure if the schema definition is complete. Can anyone improve on the schema definitions provided here or point to existing public definitions?

P.S. Somebody with more reputation points should create the tag, "json-schema".

Polygon geometry:

{
    "$schema": "http://json-schema.org/draft-06/schema#", 
    "$id":"https://some.site.somewhere/esri-polygon.json",
    "title":"esri-polygon",
    "type": "object",
    "properties": {
        "rings": {
            "title": "Rings array",
            "description": "An array of one or more rings. Unit of measure is defined by the spatial reference.",
            "type": "array",
            "items": {
                "title": "Ring array",
                "description": "An array of vertices that describe a single ring.",
                "type": "array",
                "items": {
                    "title": "Vertex or point array",
                    "description":  "An array of numbers that describe a vertex, or point. X and Y coordinates are required, with optional Z or M coordinates.",
                    "minItems": 2,
                    "maxItems": 4,
                    "items": { "type": "number" }
                }
            }
        },
        "spatialReference": {
            "type": "object",
            "properties": {
                "wkid": {"type": "integer"},
                "latestWkid": {"type": "integer"}
            }
        }
    }
}

Point geometry:

{
    "$schema": "http://json-schema.org/draft-06/schema#", 
    "$id":"https://some.site.somewhere/esri-point.json",
    "title":"esri-point",
    "type": "object",
    "properties": {
        "x": {
            "type": "number",
            "title": "Cartesian x-axis position",
            "description": "Distance along the x-axis.  Unit of measure is defined by the spatial reference."
        },
        "y": {
            "type": "number",
            "title": "Cartesian y-axis position",
            "description": "Distance along the y-axis.  Unit of measure is defined by the spatial reference."
        },
        "spatialReference": {
            "type": "object",
            "properties": {
                "wkid": {"type": "integer"},
                "latestWkid": {"type": "integer"}
            }
        }
    }
}

Line geometry:

{
    "$schema": "http://json-schema.org/draft-06/schema#", 
    "$id":"https://some.site.somewhere/esri-polyline.json",
    "title":"esri-polyline",
    "type": "object",
    "properties": {
        "paths": {
            "title": "Paths array",
            "description": "An array of one or more paths. Unit of measure is defined by the spatial reference.",
            "type": "array",
            "items": {
                "title": "Path array",
                "description": "An array of vertices that describe a single path.",
                "type": "array",
                "items": {
                    "title": "Vertex or point array",
                    "description":  "An array of numbers that describe a vertex, or point. X and Y coordinates are required, with optional Z or M coordinates.",
                    "minItems": 2,
                    "maxItems": 4,
                    "items": { "type": "number" }
                }
            }
        },
        "spatialReference": {
            "type": "object",
            "properties": {
                "wkid": {"type": "integer"},
                "latestWkid": {"type": "integer"}
            }
        }
    }
}
0

[https://jsonschema.net][1]

[1]: https://jsonschema.net provides a generic interpreter that will translate JSON data into the general format of a complete json-schema file. The interpreter creates very basic validation rules, but it can't recognize valid values from an enumeration or create effective constraints on minimum or maximum values. This is partial output from jsonschema.net for a point.

{
  "shape": {
    "$id": "#/shape",
    "type": "object",
    "title": "The Shape Schema",
    "required": [
      "shape",
      "dataSource",
      "revisionDate"
    ],
    "properties": {
      "shape": {
        "$id": "#/shape/properties/shape",
        "type": "object",
        "title": "The Shape Schema",
        "required": [
          "x",
          "y",
          "spatialReference"
        ],
        "properties": {
          "x": {
            "$id": "#/shape/properties/shape/properties/x",
            "type": "number",
            "title": "The X Schema",
            "default": 0.0,
            "examples": [
              -120.6859433
            ]
          },
          "y": {
            "$id": "#/shape/properties/shape/properties/y",
            "type": "number",
            "title": "The Y Schema",
            "default": 0.0,
            "examples": [
              39.6697349
            ]
          },
          "spatialReference": {
            "$id": "#/shape/properties/shape/properties/spatialReference",
            "type": "object",
            "title": "The Spatialreference Schema",
            "required": [
              "wkid"
            ],
            "properties": {
              "wkid": {
                "$id": "#/shape/properties/shape/properties/spatialReference/properties/wkid",
                "type": "integer",
                "title": "The Wkid Schema",
                "default": 0,
                "examples": [
                  4269
                ]
              }
            }
          }
        }
      }
    }
  }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.