In a JSONLD context one can and should declare the datatypes of props, so that a JSON payload string is mapped to the appropriate datatype.
- (This is unlike the expected range of an object property, which cannot be declared, because the type of all such props is
@is)
This is especially important for literals that don't have native JSON type (xsd:date, xsd:dateTime).
It's also important for numbers, which are subject to rounding/mangling in JSON. Eg this JSONLD payload:
{"@context":{
"xsd":"http://www.w3.org/2001/XMLSchema#",
"foo": {"@type":"xsd:boolean","@id":"https://example.org/foo"},
"foo1":{"@type":"xsd:boolean","@id":"https://example.org/foo1"},
"bar": {"@type":"xsd:decimal","@id":"https://example.org/bar"},
"bar1":{"@type":"xsd:decimal","@id":"https://example.org/bar1"},
"baz": {"@type":"xsd:integer","@id":"https://example.org/baz"}
},
"foo":"true","foo1":true,"bar":"12.345678901234567890","bar1":12.345678901234567890,"baz":123456789012345678901234567890}
is converted to this ntriples at https://json-ld.org/playground/.
Notice the rounding of bar1, and the syntactically incorrect value of baz:
_:b0 <https://example.org/bar1> "1.234567890123457E1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
_:b0 <https://example.org/bar> "12.345678901234567890"^^<http://www.w3.org/2001/XMLSchema#decimal> .
_:b0 <https://example.org/baz> "1.234567890123457E29"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:b0 <https://example.org/foo1> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b0 <https://example.org/foo> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
It's less important for booleans because the values are not subject to rounding.
Examples:
- credentials/USMCACertificationOfOrigin.yml:
importerUnknown:
title: Importer Unknown
description: >-
If the identity of the importer is unknown, or there are various
importers, please check the appropriate box.
type: boolean
$linkedData:
term: importerUnknown
'@id': https://w3id.org/traceability#importerUnknown
could add
- common/IATAAirWaybill.yml:
executedOn:
title: Executed on (Date)
description: >-
The date of execution of the air waybill shall be inserted in the sequence
of day, month and year. The month shall be expressed alphabetically,
either abbreviated or in full. Box 32A.
type: string
$linkedData:
term: executedOn
'@id': https://w3id.org/traceability#executionTime
'@type': http://www.w3.org/2001/XMLSchema#dateTime
already has @type, but maybe the JSON type should be changed from string to something better?
- common/Transport.yml:
plannedDepartureDate:
title: Planned Departure Date
description: The planned date of departure.
type: string
$linkedData:
term: plannedDepartureDate
'@id': https://schema.org/Date
Must change to this ( I assume JSON Schema has type dateTime)
type: dateTime
$linkedData:
term: plannedDepartureDate
'@id': traceability:plannedDepartureDate
'@type': xsd:dateTime
In a JSONLD context one can and should declare the datatypes of props, so that a JSON payload string is mapped to the appropriate datatype.
@is)This is especially important for literals that don't have native JSON type (xsd:date, xsd:dateTime).
It's also important for numbers, which are subject to rounding/mangling in JSON. Eg this JSONLD payload:
is converted to this ntriples at https://json-ld.org/playground/.
Notice the rounding of
bar1, and the syntactically incorrect value ofbaz:It's less important for booleans because the values are not subject to rounding.
Examples:
could add
already has
@type, but maybe the JSON type should be changed fromstringto something better?Must change to this ( I assume JSON Schema has type
dateTime)