Add semantic to the Node-RED msg payload with JSON-LD

Posted on Updated on

In the NODE-Red ecosystem, many nodes are built and published.
When someone creates a node that produces geo coordinates (this is an example), and another a node that consumes geo coordinates, it is very important that these two nodes can be linked together in NODE-Red. To achieve that, the former should produce a payload that the latter can read.

Using JSON or msg is not enough:

 "latitude" : "40.75",
 "longitude" : "73.98"

Also consider another example:

"temperature" : "40"

What does it refer to? degrees Celsius or Fahrenheit?

We must agree on the content of the JSON object in the payload.

TheThingBox choice

In the ThingBox project ( we decided to use JSON-LD to format the payload.

JSON-LD allows to uniquely define the content of a JSON object.

 "@type" : "",
 "" : "40.75",
 "" : "73.98"

When a node finds an object containing:

"@type" : ""

then the semantic of the object is uniquely defined.

The members are also uniquely defined.

The previous object can be “compacted” by factoring paths into a context:

 "@context": "",
 "@type": "GeoCoordinates",
 "latitude": "40.75",
 "longitude": "73.98"

Many objects are already defined in
Find more about JSON-LD at  and use it in Nodes!


3 thoughts on “Add semantic to the Node-RED msg payload with JSON-LD

    David Janes (@dpjanes) said:
    August 6, 2014 at 11:27 pm

    Let’s talk! I’ve been working on this for the last 18 months or so

    You’ll note (e.g.) that with the temperature above it’s a little more difficult to get a pointer to “temperature in degrees fahrenheit”. I think I’ve got all that solved.

    “@type” : “”,
    “@context”: “”,
    “latitude” : “40.75”,
    “longitude” : “73.98”

    Maybe more importantly, we’ve defined a vocabulary also for semantic control of objects, e.g. “turn this on” – and open source Node libraries to work with all of this.

    fundatrix responded:
    August 11, 2014 at 8:16 am

    Very interesting. Add links when it can help.

    David Janes (@dpjanes) said:
    August 11, 2014 at 9:06 pm

    I’ll be playing with the ThingBox soon and see how I can fit in IOTDB. A great place to start with our stuff is here:

    Code-wise Node-IOTDB fits into the ecosystem where Node-Red does, wiring components together, but using programming rather than a visual tool. Here’s a simple example of wiring a switch to a light.

    var iotdb = require("iotdb")
    var iot = iotdb.iot()
    var contacts = iot.connect("SmartThingsContact")
    var lights = iot.connect("HueLight")
    contacts.on(':open', function(thing, open_attribute, is_open) {
        lights.set(':color', is_open ? 'red' : 'green')

    And a lot lot more:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s