简体   繁体   中英

How do you escape the @ symbol in jsonpath?

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.

您显然需要使用十六进制代码(我认为这与表达式的解析方式有关)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM