How to get the pure Json string from DynamoDB stream new image?

后端 未结 6 917
不知归路
不知归路 2020-12-09 18:59

I\'ve a Dynamodb table with streaming enabled. Also I\'ve created a trigger for this table which calls an AWS Lambda function. Within this lambda function, I\'m trying read

6条回答
  •  时光取名叫无心
    2020-12-09 19:23

    In c# you can convert newImage to pure json by use of DynamoDB Document class

    using Amazon.DynamoDBv2.DocumentModel;

    var streamRecord = dynamoEvent.Records.First();

    var jsonResult=Document.FromAttributeMap(streamRecord.Dynamodb.NewImage).ToJson();


    and if you want to go further ahead to convert json to object you can use Newtonsoft

    using Newtonsoft.Json;

    TModel model = JsonConvert.DeserializeObject(jsonResult);

提交回复
热议问题