gpt4 book ai didi

json - 如何在 jsonpath 中转义特殊字符冒号 (':' )

转载 作者:行者123 更新时间:2023-12-05 03:04:01 31 4
gpt4 key购买 nike

JSON:

{
"im:rating": {
"label": "1"
}
}

尝试在 groovy 中使用 Jsonpath如果我使用这个'$.im:rating'

显示如下错误

Caused by: com.nebhale.jsonpath.InvalidJsonPathExpressionException: Illegal

character 'PathCharacter [types=[], value=:, position=4]' $.im:rating ----^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=r, position=5]' $.im:rating -----^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=a, position=6]' $.im:rating ------^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=t, position=7]' $.im:rating -------^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=i, position=8]' $.im:rating --------^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=n, position=9]' $.im:rating ---------^ Illegal character 'PathCharacter [types=[SIMPLE_NAME_CHARACTER, LETTER, COMPLEX_NAME_CHARACTER], value=g, position=10]' $.im:rating ----------^

  at com.nebhale.jsonpath.JsonPath.compile(JsonPath.java:85)
at com.nebhale.jsonpath.JsonPath.read(JsonPath.java:182)

最佳答案

$['im:rating']

Selects the specified property in a parent object. Be sure to put single quotes around the property name.Tip: Use this notation if the property name contains special characters such as spaces, or begins with a character other than A..Za..z_.https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html

关于json - 如何在 jsonpath 中转义特殊字符冒号 (':' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53294274/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com