Muleque
Muleque

Reputation: 91

AWS IOT Core Rule wrong JSON formatting in DynamoDB

I am using AWS IOT Core to store incoming data in a DynamoDB table. The message payload looks like this:

{
  "temperature": "8",
  "humidity": "80"
}

The Rule Query:

SELECT temperature, humidity FROM '+/pub'

And the resulting entry in the DynamoDB table:

{"temperature":{"N":"26"},"humidity":{"N":"34.20000076"}}

What I expected:

{"temperature":"26","humidity": "34.20000076"}

I understand that these additional keys are value type identifiers but I do not see why I would need them and how they got there.

Upvotes: 0

Views: 154

Answers (1)

Leeroy Hannigan
Leeroy Hannigan

Reputation: 19803

DynamoDB does not persist data in native JSON but with DynamoDB-JSON, which is why you see the identifiers when you read back the data.

I'm not sure on the IOT Core implementation but if you're using the DynamoDB SDK you can avoid those values by using a higher level client such as Document Client for JS. You can also use the built in converter's unmarshall the data to native JSON.

Upvotes: 1

Related Questions