1

Some Watson IoT samples use a d in device payloads {"d":{"temp":20}}. As here in embedded c: :

"{\"d\" : {\"temp\" : 34 }}"

Others don't use this d, they just send in format {"temp":20}. Like this java sample:

//Generate a JSON object of the event to be published
                  JsonObject event = new JsonObject();
                  event.addProperty("name", "foo");
                  event.addProperty("cpu",  90);
                  event.addProperty("mem",  70);

Both work but I've had situations where I had to put in a d as a downstream app failed - and they said it was part of the api specification. I couldn't find that it actually is part of any specification. To d or not to d, that is the question?

amadain
  • 2,724
  • 4
  • 37
  • 58

1 Answers1

1

All data is carried under a top level "d" element and an optional "ts" element exists, containing a timestamp for the message. If no ts element is present, the timestamp defaults to the time the message is received.

According to Bryan from the IoT team here:

IoT Foundation doesn't explicitly require a "d" top-level property in the JSON payload, however it does encourage this format to allow IoT Foundation to make some assumptions about how data is organized in the payload. If the IoT Foundation payload format is not followed, we refer to this as a "custom payload" in our documentation. IoT Foundation will allow you to publish a custom payload...

joe
  • 2,468
  • 2
  • 12
  • 19
  • Thanks, so there is actually a reason! Probably the people writing those d-less samples didn't realize this either. – amadain Apr 04 '17 at 14:32