在 AWS Lambda 中将 DynamoDB 数据格式化为普通的 JSON [英] Formatting DynamoDB data to normal JSON in AWS Lambda
问题描述
我正在使用 AWS Lambda 从 DynamoDB 表中扫描数据.这就是我得到的回报:
I'm using AWS Lambda to scan data from a DynamoDB table. This is what I get in return:
{
"videos": [
{
"file": {
"S": "file1.mp4"
},
"id": {
"S": "1"
},
"canvas": {
"S": "This is Canvas1"
}
},
{
"file": {
"S": "main.mp4"
},
"id": {
"S": "0"
},
"canvas": {
"S": "this is a canvas"
}
}
]
}
我的前端应用程序正在使用 Ember Data Rest Adapter,它不接受此类响应.有什么办法可以获得正常的 JSON 格式吗?有一个名为 dynamodb-marshaler
的 NPM 模块可以将 DynamoDB 数据转换为普通的 JSON.如果可能,我正在寻找本地解决方案.
My front-end application is using Ember Data Rest Adapter which does not accepts such response. Is there any way I can get normal JSON format? There is this NPM module called dynamodb-marshaler
to convert DynamoDB data to normal JSON. I'm looking for a native solution if possible.
推荐答案
AWS JavaScript SDK 最近更新了 Document Client,它完全可以满足您的需求.在此处查看公告和使用示例:http://blogs.aws.amazon.com/javascript/post/Tx1OVH5LUZAFC6T/Announcing-the-Amazon-DynamoDB-Document-Client-in-the-AWS-SDK-for-JavaScript
AWS JavaScript SDK was recently updated with Document Client which does exactly what you need. Check the announce and usage examples here: http://blogs.aws.amazon.com/javascript/post/Tx1OVH5LUZAFC6T/Announcing-the-Amazon-DynamoDB-Document-Client-in-the-AWS-SDK-for-JavaScript
这篇关于在 AWS Lambda 中将 DynamoDB 数据格式化为普通的 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!