在 AWS Lambda 中将 DynamoDB 数据格式化为普通 JSON [英] Formatting DynamoDB data to normal JSON in AWS Lambda

查看:24
本文介绍了在 AWS Lambda 中将 DynamoDB 数据格式化为普通 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆