在步骤功能中过滤Dynamo DB JSONPATH
我正在尝试构建一个步骤函数,该步骤函数在Dynamo DB MAP的结果中基于映射的选择状态。我的Dynamo GetItem请求的示例结果是。
{
"Item": {
"organisationId": {
"S": "Andys-test"
},
"id": {
"S": "Andy2"
},
"states": {
"L": [
{
"M": {
"year": {
"N": "2021"
},
"status": {
"S": "started"
}
}
},
{
"M": {
"year": {
"N": "2022"
},
"status": {
"S": "started"
}
}
}
]
},
},
我的状况将检查状态与2021年相对的状态。我试图使用此JSONPATH,从我可以看出的有效的情况下,尽管我在步骤函数控制台中的数据流模拟器中什么都没得到。我尝试了以下各种迭代,引号逃脱了引号等,无法获得任何内容来解析正确的价值。 我一直在输入选择器中进行此操作,因为我可以看到结果路径不支持[?()]符号。
$.Item.states.L..M[?(@.year.N == 2022) ]
I am trying to build a step function that has a choice state based on a map in a result of a dynamo db map. An example result from my dynamo GetItem request would be.
{
"Item": {
"organisationId": {
"S": "Andys-test"
},
"id": {
"S": "Andy2"
},
"states": {
"L": [
{
"M": {
"year": {
"N": "2021"
},
"status": {
"S": "started"
}
}
},
{
"M": {
"year": {
"N": "2022"
},
"status": {
"S": "started"
}
}
}
]
},
},
My condition will be checking the status of the states map against the year 2021. I have attempted to use this JSONPath which from what I can tell is valid, although I am getting nothing in the data flow simulator in the step functions console. I have tried various iterations of the below, with quotes escaped quotes etc and can't get anything to parse the correct value out.
I have been doing this in the input selector as I can see that the result path does not support the [?()] notation.
$.Item.states.L..M[?(@.year.N == 2022) ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有一些规则的示例选择状态,就很难确切地回答,但我认为我正在关注。
与表达式过滤器的JSONPATH相比,
我遇到的问题要比使用JsonPath滤波器表达式时想要的更频繁地遇到这种问题,并且必须添加“助手”任务才能使事情移动(浪费宝贵的状态过渡
Without an example choice state with some rules, it'll be hard to answer definitively but I think I'm following.
JSONPath with expression filters
I run into this sort of problem more often than I'd like when using JSONPath filter expressions and have to add "helper" tasks to get things moving (wasting valuable state transitions ???? ).
When you specify a Path that includes a filter expression, the result is always going to be a list (and you won't be able to reference index afterwards either).
ChoiceRules don't really have a comparator that deals with arrays/lists (at least i haven't been able to get it to work, so let me know if you do ????).
The hack I've found easiest to reason about/maintain is creating a simple Pass Task that "pops" the values I need from the filter expression and then pass that along to the Choice Task.
Here's an example from one of my previous answers (the pattern used in the
PassDef
task would be defined before your choice task in your scenario, instead of after)I've found it easier to start with https://jsonpath.herokuapp.com then progress to the data flow simulator. Just remember to always keep in mind whether
you're trying implement a
Path
or aReference Path
!