I am trying to process dynamoDB streams based on changes in a table.
The items from the stream have the data type present in the stream.
I am trying to find a library similar to dynamodb-data-types, which can unwrap the dynamoDB structure to json structure for python. My lambda is in python.
Eg: I am trying to convert
{
"fruit": {
"S": "Apple"
},
"count": {
"N": "12"
}
}
to
{
fruit: 'Apple',
count: 12
}
I tried to search in the wrb, but was unable to find and solution.
If there is no such library, what do you think is the best way to handle this myself.
Edit:
Currently I am achieving this using(I am not sure if this is the recommended way):
def cleanDynamoDBStream(record):
newImage = record["dynamodb"]["NewImage"]
for key, dynamoDBValue in newImage.items():
for dataType, value in dynamoDBValue.items():
newImage[key] = value
return newImage