Copyright © 2015 Open Geospatial Consortium.
13
ServiceIdentification:{ Title: The title
} }
By doing so, all JSON elements that are associated to a namespace URI can be dereferenced into a full URL when transformed to other RDF encoding such as nquads.
Nquads examples in this document illustrate this mechanism.
5.3.2 Using JSON-LD to declare simple and complex types.
In JSON-LD we can declare the data type of all keys in a JSON file. When type is not declared a string type is assumed. This is valid for simple types generality declared by
using the http:www.w3.org2001XMLSchema normally abbreviated as “xsd”.
{ context: {
xsd: http:www.w3.org2001XMLSchema, discharge: {
id: http:www.opengis.uab.catriverdischarge, type: xsd:float,
} }
discharge: 3.14 }
On the other hand complex types that can be defined by any other namespace e.g.: http:schema.org”. You can declare that an object is of a complex type by adding a
type property or a synonymous of “type” to it.
{ context: {
geojson: http:ld.geojson.orgvocab, type: type,
} geometry: {
type: geojson:LineString, coordinates: [
[-95.2075, 47.239722], [-89.253333, 29.151111] ]
} }
The way complex data types are defined is out of scope of the JSON-LD specification that relies on the RDF way of defining complex types and vocabularies in OWL or
SKOS.
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