我正试图使用DynamoPutItem任务放置一个条目,该条目包括对象的列表作为其属性之一。我在网上找不到任何这样做的例子,所以我想知道这是否可能?
这个CDK问题似乎在谈论同样的事情,但这对我来说不起作用,我想知道这只适用于字符串列表而不是对象吗?
下面是一个我试图放入DDB:的项目的简化示例
{
'someKey': 'This will be fine',
'anotherKey': [
{
'ohoh': 'This object and the list it belongs will cause an error'
}
]
}
我尝试了许多DynamoAttributeValue和JsonPath的组合,但都没有成功:(
以下是我尝试过的一些代码的示例:
new DynamoPutItem(this, 'some id here', {
item: {
// this will be fine
someKey: DynamoAttributeValue.fromString(JsonPath.stringAt('$.someKey'),
// this will cause an error
anotherKey: DynamoAttributeValue.listFromJsonPath(JsonPath.stringAt('$.anotherKey')),
},
table: myTable,
}
以及它抛出的错误:The field "ohoh" is not supported by Step Functions
如果我在这里阅读文档,你似乎需要使用:
DynamoAttributeValue.listFromJsonPath(value: anotherKey)