【问题标题】:JSONPath expression works with Data flow simulator but not with step functionsJSONPath 表达式适用于数据流模拟器,但不适用于步进函数
【发布时间】:2021-12-31 13:18:09
【问题描述】:

我正在尝试使用 AWS Step Functions 中的 InputPath 过滤器来选择 JSON 状态输入的一部分以与 JSONPath 表达式一起使用。

数据

[
  {
    "ticker": "DE30_EUR",
    "granularity": "M"
  },
  {
    "ticker": "DE30_EUR",
    "granularity": "W"
  },
  {
    "ticker": "DE30_EUR",
    "granularity": "D"
  },
  {
    "ticker": "DE30_EUR",
    "granularity": "H1"
  }
]

当前 JSONPath 表达式

$[?(@.granularity==H1),?(@.granularity==D),?(@.granularity==W)]

这在使用带有上述数据的 AWS Step Functions 数据流模拟器时有效,并且仅返回粒度为“H1”、“D”或“W”的数组项。

问题

但是,当将此与 step 函数一起用作 InputPath 或 OutputPath 时,它会返回一个与数据流模拟器不同的空数组。

【问题讨论】:

    标签: amazon-web-services jsonpath aws-step-functions


    【解决方案1】:

    试试下面的JSONPath

    $[?(@.granularity=='H1'|| @.granularity=='D' || @.granularity=='W')]
    

    【讨论】:

    • 这是我最初尝试使用 AWS 数据流模拟器的方法,但它失败并出现错误 No results for path: '$[?(@.granularity=='H1'|| @.granularity=='D' || @.granularity=='W')]' in state input JSON. 但我现在使用步进函数再次尝试,你是对的,它确实有效。似乎数据流模拟器语法与步骤函数语法不一致。
    猜你喜欢
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 2012-11-01
    • 2011-03-08
    • 2015-02-13
    相关资源
    最近更新 更多