JSON Schemas
JSON Schema is a declarative language used to describe and validate the structure, content, and constraints of JSON data. It ensures consistency and integrity by defining rules for JSON documents, ma…
JSON Schema is a declarative language used to describe and validate the structure, content, and constraints of JSON data. It ensures consistency and integrity by defining rules for JSON documents, making it easier to validate and interpret data.
This article briefly describes how JSON schemas are used for data validation within the Global Traceability Framework for Beef and Leather (GTFBL). For a detailed explanation of how JSON schemas work, refer to the official JSON Schema documentation.
Validation with JSON Schemas
Traceability data within the GTFBL is expected to fit the JSON-LD bindings defined in the EPCIS 2.0 standard. This data is then validated by comparing it to the EPCIS 2.0 JSON Schemas available in GS1's public code repository. If there are any validation errors, the data is considered invalid.
Example
The JSON Schema for the eventType property is as follows:
{
"eventType": {
"anyOf": [
{
"type": "string",
"enum":[
"ObjectEvent",
"AggregationEvent",
"AssociationEvent",
"TransformationEvent",
"TransactionEvent"
]
},
{
"type": "string",
"format": "uri"
}
]
}
The above schema clarifies that the eventType property for an event must be one of the following string values:
- ObjectEvent
- AggregationEvent
- AssociationEvent
- TransformationEvent
- TransactionEvent
or, any string that is formatted as a uri.
How did we do?
Technical Implementation Background
Master Data Mapping