如何在JSONPath查询中使用相等运算符过滤出type为error的消息?
解决JSONPath过滤type为error条目的问题
要实现只提取issues数组中type为error的条目及其type和message字段,你需要在原JSONPath查询中添加过滤条件。
正确的JSONPath查询语句
@.records[*].issues[?(@.type == 'error')].[type, message]
语句解释
records[*]:遍历所有records数组中的记录项issues[?(@.type == 'error')]:针对每个记录的issues数组,筛选出**当前元素的type属性等于'error'**的条目。这里的@代表正在遍历的issues元素本身.[type, message]:从过滤后的元素中提取type和message两个字段
执行结果
运行上述查询后,你会得到仅包含error类型的结果:
[ [ "error", "[SQ] Task failed with status FAILED, Error message: Fail to extract report AYOEa2gdtfNdJFd6edM9 from database" ] ]
内容的提问来源于stack exchange,提问作者eliassal
相关产品推荐
相关产品推荐

