How to avoid the @ character in jsonpath?

Given a json list, for example:

{ "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 to select a value in "custentity_bar_number"? 166493?

This will take you there, but only if you remove the @ symbol before @scriptId in JSON.

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

So, I need a way to escape the @ character in json and do something like this work:

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

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

+8
json jsonpath
source share
2 answers

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

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

Using hex code to exit @simbol does not work for me. Here is an example of what I have tried.

This is a sample JSON:

 { "firstName": "John", "lastName" : "doe", "age" : 26, "@address" : { "streetAddress": "naist street", "city" : "Nara", "postalCode" : "630-0192" } } 

And these are the jsonpaths I tried:

 $.'\x40address'[*] $."\x40address"[*] 

A simple online tool where I was able to try this out was http://jsonpath.com/

Do you have any suggestions on what I might have missed?

0
source share

All Articles