Unmarshall DynamoDB JSON [英] Unmarshall DynamoDB JSON
问题描述
通过DynamoDB NewImage流事件提供一些 DynamoDB JSON ,如何将其解编为常规JSON ?
Given some DynamoDB JSON via a DynamoDB NewImage stream event, how do I unmarshall it to regular JSON?
{"updated_at":{"N":"146548182"},"uuid":{"S":"foo"},"status":{"S":"new"}}
通常我会使用 AWS.DynamoDB.DocumentClient ,但是我似乎找不到通用的Marshall / Unmarshall函数。
Normally I would use AWS.DynamoDB.DocumentClient, however I can't seem to find a generic Marshall/Unmarshall function.
旁注:我会丢失将 DynamoDB JSON 解组为JSON并再次返回的内容吗?
Sidenote: Do I lose anything unmarshalling DynamoDB JSON to JSON and back again?
推荐答案
您可以使用 AWS.DynamoDB.Converter.unmarshall
函数。调用以下命令将返回 {Updated_at:146548182,uuid:'foo',status:'new'}
:
You can use the AWS.DynamoDB.Converter.unmarshall
function. Calling the following will return { updated_at: 146548182, uuid: 'foo', status: 'new' }
:
AWS.DynamoDB.Converter.unmarshall({
"updated_at":{"N":"146548182"},
"uuid":{"S":"foo"},
"status":{"S":"new"}
})
可以用DynamoDB的编组JSON格式建模的所有内容都可以安全地与JS对象进行转换。
Everything that can be modeled in DynamoDB's marshalled JSON format can be safely translated to and from JS objects.
这篇关于Unmarshall DynamoDB JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!