简体   繁体   English

映射“ M”类型的dynamodb boto put_item

[英]dynamodb boto put_item of type Map “M”

Has anyone successfully performed a put operation of a map into dynamodb using boto (python)? 有谁成功使用boto(python)将地图放入dynamodb的放置操作?

I basically need to put a json object. 我基本上需要放置一个json对象。 So far I have only been able to put it as json string but I cannot find an example of inserting a map anywhere. 到目前为止,我只能将其作为json字符串放置,但是找不到在任何地方插入地图的示例。

Thanks a lot. 非常感谢。

Since it does not looks like boto supports JSON in its high-level API interface, you have to use the low-level API interface and annotate your JSON object into a DynamoDB-supported wire format as such: 由于boto似乎在其高级API接口中不支持JSON,因此您必须使用低级API接口,并将JSON对象注释为DynamoDB支持的有线格式,如下所示:

"time": {
    "M": {
      "creation_timestamp_utc": {
        "S": "2012-08-31T03:35:56.881Z"
      },
      "localtime": {
        "S": "12:25:31"
      },
      "received_timestamp_utc": {
        "S": "2012-08-31T07:50:50.367Z"
      },
      "spacecraft_clock": {
        "S": "399657440.746"
      }
    }

In the above snippet, M is used to denote a "map" object, and S is used to denote the attribute type of each of the entries. 在以上代码段中,M用于表示“地图”对象,而S用于表示每个条目的属性类型。 You can find more information on what annotations to use for each type here . 您可以在此处找到有关每种类型使用哪些注释的更多信息。

I can understand why this is extremely annoying to do though, so you could always open an issue (perhap there is already one opened) at https://github.com/boto/boto/issues/new so they are aware of the feature request. 我可以理解为什么这样做非常烦人,所以您可以随时在https://github.com/boto/boto/issues/new上打开一个问题(也许已经打开了一个问题),以便他们知道该功能请求。

Support for Maps and Lists is now available in boto v2.35: https://github.com/boto/boto/issues/2737 Boto v2.35中现已提供对地图和列表的支持: https : //github.com/boto/boto/issues/2737

To upgrade: pip install -U boto 升级: pip install -U boto

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM