How do you escape the @ symbol in jsonpath?

2019-06-17 02:25发布

Given a json list like this:

    {    
 "listRel:customFieldList": {
            "platformCore:customField": [
              {
                "@internalId": "801",
                "scriptId": "custentity_admin_contact_cweb",
                "@xsi:type": "platformCore:BooleanCustomFieldRef",
                "platformCore:value": "false"
              },
              {
                "@internalId": "712",
                "@scriptId": "custentity_bar_number",
                "@xsi:type": "platformCore:StringCustomFieldRef",
                "platformCore:value": "166493"
              },
              {
                "@internalId": "798",
                "@scriptId": "custentity_contact_type",
                "@xsi:type": "platformCore:SelectCustomFieldRef",
                "platformCore:value": {
                  "@internalId": "1",
                  "@typeId": "148",
                  "platformCore:name": "Attorney"
                }
              }
              ]
 }
}

How can I select the value in "custentity_bar_number"? 166493?

This will get you there, but only if you delete the @ symbol in front of @scriptId in the JSON.

$..['platformCore:customField'][?(@['scriptId'] == 'custentity_bar_number')]

So what I need is a way to escape the @ symbol in the json, and make something like this work:

$..['platformCore:customField'][?(@['@scriptId'] == 'custentity_bar_number')]

I am using http://jsonpath.com/ to try and make this work.

标签: json jsonpath
1条回答
Anthone
2楼-- · 2019-06-17 02:49

You apparently need to use the hex code (I think it has something to do with the way the expression is being parsed)

$..['platformCore:customField'][?(@['\x40scriptId'] == 'custentity_bar_number')]
查看更多
登录 后发表回答