Unmarshall DynamoDB JSON

Given some DynamoDB JSON via DynamoDB NewImage stream event, how do I unmount it to regular JSON?

{"updated_at":{"N":"146548182"},"uuid":{"S":"foo"},"status":{"S":"new"}}

      

I usually used AWS.DynamoDB.DocumentClient , however I cannot find a generic Marshall / Unmarshall function.

Sidenote: Am I losing anything unmarshalling DynamoDB JSON to JSON and back?

+3


source to share


1 answer


You can use the function AWS.DynamoDB.Converter.unmarshall

. Calling the following returns { updated_at: 146548182, uuid: 'foo', status: 'new' }

:

AWS.DynamoDB.Converter.unmarshall({
    "updated_at":{"N":"146548182"},
    "uuid":{"S":"foo"},
    "status":{"S":"new"}
})

      



Anything that can be modeled in JSON format in DynamoDB format can be safely translated into and out of JS objects.

+6


source







All Articles