Decoding and parsing JSON using NewtonSoft

So you are working with JSON, you get a JSON message and you want to retrieve some values from it. How?

Let’s suppose you get something like (this is an example take from here):


The backslashes, the escape characters, are only for C# to know which double quotes are part of the message. It’s not necessary but you can remove them and then you have:


Well, it’s always good to check the message is proper JSON. You can check it with a ‘tool’ like


This is a valid message, if we format the structure, it looks a lot better:

  "port": 1,
  "counter": 504,
  "payload_raw": "+QA=",
  "payload_fields": {
    "errorCode": 0,
    "numberOfCycles": 249
  "metadata": {
    "time": "2017-01-10T23:31:06.087189682Z",
    "frequency": 868.1,
    "modulation": "LORA",
    "data_rate": "SF7BW125",
    "coding_rate": "4/5",
    "gateways": [{
      "gtw_id": "eui-b827ebffffc19ca8",
      "gtw_trusted": true,
      "timestamp": 3771642998,
      "time": "1754-08-30T22:43:41.128654848Z",
      "channel": 0,
      "rssi": -80,
      "snr": 9,
      "latitude": 51.46018,
      "longitude": 5.61902,
      "altitude": 10}]

There are several ways to get values from this JSON message.

Continue reading “Decoding and parsing JSON using NewtonSoft”


Internet button, Domoticz and Microsoft Flow in Unison

For a few weeks now, I have my personal Domotics solution. I could have bought a complete solution but rather I was intrigued by Domoticz. It’s an open source Home Automation System and what’s really great, it interacts with all kinds of communication protocols.

Basically, you need a device which can run a web server and you need a local gateway for the transmission of the various signal.

This is how my rig looks like:


Continue reading “Internet button, Domoticz and Microsoft Flow in Unison”