JSON-LD Support on Platform

Disponible a partir de versión 4.0.0-nitroball

Introduction

JavaScript Object Notation for Linked Data is a JSON-based method for adding structured data, completing the JSON annotation with context elements so that the semantic relationships that give it meaning can be understood.

Plataforma supports JSON-LD on its ontologies, being able to collect or insert data via API Rest in JSON-LD format, indicating the desired context. In this way, the data inserted in the ontologies can be returned in normal JSON format, or with its context.

Onesait Platform allows you to register the JSON-LD models you intend to use, just as it does with models in Json Schema format.

How to create JSON-LD Entities?

Thus, if you want an ontology to support the JSON-LD format, you must check the corresponding checkbox when creating or editing the ontology, in addition to informing its context.

In the step-by-step creation, selecting the JSON-LD support will show the available JSON-LD models and selecting any of them will show the structures offered by that schema, being able to make multiple selections by holding down the Ctrl key while selecting. Once the continue button is pressed, the ontology data will be filled in with the properties defined for that schema.

The structure of the ontology will be created with the properties defined for each type of data chosen, thus, if you want to include the properties of two concepts with inheritance, it will be necessary to select both of them, otherwise only those corresponding to the child class will be added.

In addition, it is necessary to take into account that the data type of each property will be String in the case of being another class of the schema and not being a simple data type such as string, number, integer, date, boolean, etc. In this way, it will be possible to reference the corresponding id with the data of another ontology that complies with the schema.

For example, inSchema.org Person has an address field which can be of type Text (simple) or of type PostalAddress which is another class defined in Schema.org. In this case the ontology schema will be formed by allowing to enter a text, which can be the identifier of the address entered in bbdd in another ontology that complies with the PostalAddress schema, thus having the address-person relationship.

If you need it to be an object, you will have to edit it in this screen and define it after clicking on the Update Schema button.

In the rest of ontology creations, time series, api rest, etc. the context can be indicated by entering the text directly. In this way it will be necessary to define the properties manually in the following screen.

If you wish to edit the ontology once it has been created, you must take into account that the context cannot be edited, since it would be necessary to change the complete structure of the ontology. The changes you will be able to make will be to add or remove properties, in addition to the rest of the ontology's own changes.

How to query data in JSON-LD?

Once we have created our Entity, we will create an API with the basic GET and POST operations. In this way, we will be able to select from the generated swagger, or via Postman for example, the type of data we send or wish to receive.

If our ontology supports JSON-LD format, it will be possible to insert data in this format, as in normal JSON format, always indicating it in the Request body ("Content-Type: application/ld+json").

In GET operations, this must be indicated in the response ("accept: application/ld+json").

In case the ontology does not support the JSON-LD format, the API will return an error 406 Not Acceptable.

In this way, the data is returned with the desired format, indicating the context and the type of data used (@type).

 

Â