14
Copyright © 2015 Open Geospatial Consortium.
On the other hand, JSON schema do allow for complex types definition:
{ type: object,
required: [ type, id, properties], properties: {
id : { type: string, format: uri }, type: { enum: [ Feature ] },
geometry: { ref: definitionsgeometry }, properties: {
type: object }
} }
5.4 XML Schema, Schematron, JSON Schema, JSON-LD validation
The creation of a context section in a JSON-LD introduces many elements that look similar to the ones introduced in JSON Schema. It seems reasonable to suppose that
JSON-LD could be used by a validating algorithm to validate a JSON file in a similar way that JSON Schema does. The table 2 summarizes the capabilities provided by
different validation strategies.
Table 2: Comparison of different validation approaches Validation functionality
XML Schema
Schematron JSON Schema
JSON-LD
Data types yes
limited
4
yes Limits in simple data types
yes yes
yes no
Declare object of complex types
yes no
yes yes
Define complex data types yes
yes no
1
Mandatory properties multiplicity one in objects
yes yes
no
1
More than one multiplicity of properties in objects
yes Will be
arrays
3
no controlled
Order of the properties in objects
yes no
no no
Object tree dependency yes
yes with id’s
Copyright © 2015 Open Geospatial Consortium.
15 and links
Links between objects xlink
not yet clear
with type:id
Unknown properties yes
no
2
yes Unknown objects
yes no
2
yes Namespaces
yes yes
no yes by
definition all keys are
full URIs
Conditional rules no
yes no
no Connection to RDF
no no
no yes
1
Could be provided by the vocabulary pointed by the URIs
2
JSON is considered more flexible and extensible so an unknown property is considered an extension and it is ignored.
3
use “type”:”array”, minItems : min, maxItems: max: http:stackoverflow.comquestions23141511how-to-map-uml-composition-
cardinality-to-json-schema
4
limited to the JSON data types: “string”, “number”, “object”, “array”...
The authors of this ER believe that JSON-LD could be used as a validation strategy with the adoption of some additional conventions. In fact, many examples in this document
have been validated using the JSON-LD playground. It is out of scope of this ER to try to completely assess this possibility but the authors recommend doing additional testing in
the future.
Recommendation 4: Consider the combined use of JSON schema and the context section of a JSON-LD file possibly in combination with the ontologies linked to it as a means for validating a
JSON file in the OGC. The next OGC Testbed could include a test on this approach as an activity. Target: Testbed-12
Recommendation 5: Consider the possibilities of using the namespace URIs in context section of a JSON-LD file as a means to connect to formal ontologies structured in OWL SKOS or other RDF
encoding as a way to validate complex types in JSON files in the OGC. The next OGC Testbed could include a test on this approach as an activity.
Target: Testbed-12
NOTE: https:developers.google.comstructured-datatesting-tool that will be mentioned later already verifies complex data structures in files written in JSON-LD and a similar approach is suggested here.