JSON-LD/NGSI-LD workshop - Matteo Basile

Tags: nelenschuurmans, rdf

The/my background

The company I work for (Nelen & Schuurmans) is a member of the EU ‘TEMA’ project. TEMA stands for trusted extremely precise mapping and prediction for emergency management. A main focus for us is to improve our ‘3Di’ hydrodynamic computation software.

But… such a flood calculation program doesn’t function in a vacuum, it needs input and something useful has to done with its output :-) The TEMA project has prepared a couple of technologies to help with that:

  • A kubernetes cluster. That’s scary, so that’s why I was asked to take a look.

  • A semantic web server (that’s how I’d call it). NGSI-LD, using JSON-LD. That’s what the summary below is actually about.

But first I want to get a bit enthousiastic about that semantic web part. I’ve attached the tag rdf to this blog entry. Json-ld is basically “rdf in json form”. RDF is a way of linking information with URLs, like json-ld. So not just textual author="reinout", but http://purl.org/dc/terms/creator="https://reinout.vanrees.org" or something like that.

I could point at a piece of my PhD thesis where I describe RDF… anyway, I’m quite enthousiastic about finally doing a little bit of work with semantic web technologies :-)

The actual talk

Json is a data exchange format, but it isn’t understandable for machines. Also for humans, it is not understandable out of the box. name=”John”: is that the first name? Or the username? Or the name of a book?

JSON-LD is an extension to json that annotates attributes with extra information. An attribute is turned into a URI with a specific meaning. A json document has an associated schema. Schemas are associated by a @context atttribute pointing at the schema.

You can define a Person type with a name attribute that precisely says it is the name of the person. Inheritance is also possible: a Policeman can be a kind of Person.

NGSI-LD: next generation service interface - linked data is an open standard for context information management. “Context” means such a JSON-LD-defined schema. NGSI-LD 1.0 started already in 2012. The start of the current version was in 2017.

An entity consists of id, type and scope. An entity is stored in (or owned by) a “tenant”: a separate database. Tenants are isolated, so you can have security and access rights. A “context broker” is connected to several tenants and can handle access to them. To work around possible ID collisions between tenants, the “full” id of an entity is the combination between tenant+id.

Within such a context broker, you can search according to a “scope”. Entities can belong to multiple scopes. Scopes can be nested.

An entity is a tangible object in the physical world. It can have attributes (via json-ld). An attribute has a type, a name and a value. Type can be a regular property, a geo property, a temporal property, a list property (a list of values instead of a single value), etc.

If needed, an attribute can itself have a sub-attribute. “speed=20” can have “measured_at=14:00” and “unitCode=km/h” sub-attributes, for instance.

To access the data, you have to talk to the API. The api supports three types of json-ld:

  • Normalized (the most verbose, but also the most complete and interoperable).

  • Concise.

  • Simplified.

The @context is the semantic context of the data in a resource.

The API supports the regular CRUD (create, read, update, delete) actions. Very important: the filtering. You can filter by id, by type, a geoquery and more. Advanced queries can be done with the “ngsi-ld query language”.

Subscriptions are a mechanism for receiving real-time notifications. You subscribe to the results of a filter: when something changes, you get a notification via http or mqtt. The context broker sends the notifications.

  • Which entities do you want to watch?

  • What attributes do you want to watch? And what is the condition? (“temperature>20”).

  • What is the endpoint (=url) you want the notification to go to?

vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):