0

How can I convert a DynamoDB view JSON to a normal JSON in Rust?

For example, I want to convert:

{
 "id": {
  "N": "123"
 },
 "name": {
  "S": "some name"
 }
}

to this:

{
 "id": 123,
 "name": "some name"
}

I've found this question Formatting DynamoDB data to normal JSON in AWS Lambda with several answers for Node.js or Python.

Is there a converter like unmarshall (JavaScript) or TypeDeserializer.deserialize (Python) for Rust in the aws-sdk-rust?

fedonev
  • 20,327
  • 2
  • 25
  • 34
rherrmannr
  • 88
  • 6
  • You can try using the from_attribute_map method of the serde_dynamodb::from_dynamodb trait. `let item: Item = from_dynamodb(serde_json::from_str(dynamodb_json).unwrap()).unwrap();` – makit Dec 09 '22 at 11:07
  • Therefore, I'd need to use `rusoto_dynamodb`, but I'd like to use `aws-sdk-dynamodb`. So this won't work out of the box. – rherrmannr Dec 09 '22 at 13:09

0 Answers0