0

The discussion at json decimal question sounds like the answer but it seems only to work for simple strings. I have a JSON object with lists embedded in it like [Decimal('-9.1'), Decimal('10.1')]. I want it to be simply [9.1,10.1]. I cannot download a library and use it because it has to work in AWS Lambda.

The reason I have this is that AWS DynamoDB requires the Decimal tag.

I found an awkward workaround: traverse the tree that is the dictionary and replace each numeric item with a quoted string. This requires code that knows in detail where the numbers are in the dictionary. Is there a way to store numbers in Dynamo DB objects that is serializable?

Anna Naden
  • 187
  • 10

1 Answers1

0

An awkward solution was use an attached handler to json.loads to convert the floating point numbers to strings. Another solution, suggested on Stack Exchange, would be to serialize the dictionary locally and, instead of writing the dictionary to DynamoDb, write the serialized string to S3

Anna Naden
  • 187
  • 10