JMESPath 将字符串转换为数字然后按大于 0 的值进行过滤得到 "Invalid token (Number): "0"" 错误消息
JMESPath cast string to number then filiter by greater than 0 get "Invalid token (Number): "0"" error message
我想获取 pretaxCost > 0
数据,但我遇到了如下问题:
我的 JMESPath
[?pretaxCost.to_number(@) > 0]
演示数据:
[
{
"pretaxCost": "7.19999999999999962124684594298729134465020251809619367122650146484375E-8",
"instanceName": "demo202009210002"
},
{
"pretaxCost": "0",
"instanceName": "demo202009210002"
},
{
"pretaxCost": "0",
"instanceName": "demo20092701"
},
{
"pretaxCost": "0.2399999999999999911182158029987476766109466552734375",
"instanceName": "demo965546464"
},
{
"pretaxCost": "0.06278620880000000681331329133172403089702129364013671875",
"instanceName": "weihanacrdemo"
},
{
"pretaxCost": "2.16000000000000001872295179138061538282045148662291467189788818359375E-7",
"instanceName": "092d02d45a464c1291715701"
}
]
系统显示错误信息:
jmespath.min.js:2 Uncaught ParserError: Invalid token (Number): "0"
我的想法:
我认为 pretaxCost 是字符串类型,所以我必须将类型转换为数字,所以我使用 to_number
函数,然后使用表达式 > 0
来获得我预期的结果,但它不起作用..
我只尝试 select pretaxCost to_number 就像下面的演示一样工作:
JSFiddle - Code Playground
我读了文档JMESPath Examples — JMESPath
我尝试了下面的表达式,它起作用了
[?pretaxCost.to_number(@) > `0`]
系统必须使用
`number`
我想获取 pretaxCost > 0
数据,但我遇到了如下问题:
我的 JMESPath
[?pretaxCost.to_number(@) > 0]
演示数据:
[
{
"pretaxCost": "7.19999999999999962124684594298729134465020251809619367122650146484375E-8",
"instanceName": "demo202009210002"
},
{
"pretaxCost": "0",
"instanceName": "demo202009210002"
},
{
"pretaxCost": "0",
"instanceName": "demo20092701"
},
{
"pretaxCost": "0.2399999999999999911182158029987476766109466552734375",
"instanceName": "demo965546464"
},
{
"pretaxCost": "0.06278620880000000681331329133172403089702129364013671875",
"instanceName": "weihanacrdemo"
},
{
"pretaxCost": "2.16000000000000001872295179138061538282045148662291467189788818359375E-7",
"instanceName": "092d02d45a464c1291715701"
}
]
系统显示错误信息:
jmespath.min.js:2 Uncaught ParserError: Invalid token (Number): "0"
我的想法:
我认为 pretaxCost 是字符串类型,所以我必须将类型转换为数字,所以我使用 to_number
函数,然后使用表达式 > 0
来获得我预期的结果,但它不起作用..
我只尝试 select pretaxCost to_number 就像下面的演示一样工作:
JSFiddle - Code Playground
我读了文档JMESPath Examples — JMESPath
我尝试了下面的表达式,它起作用了
[?pretaxCost.to_number(@) > `0`]
系统必须使用
`number`