Extract Variables JSONPayload JSONPath escape character

Is there a way to escape characters in the JSONPath of the JSONPayload of the Extract Variables policy?

 

For example:

<JSONPayload>
   
<Variable name="name" type="string">
     
<JSONPath>comics.title.spider.man</JSONPath>
   
</Variable>
</JSONPayload>

Is there a way to escape the '.' between spider and man to get a literal '.' and get spider.man as a single object?

 

Solved Solved
0 2 806
1 ACCEPTED SOLUTION

If spider.man is an object, then i think what you want to do is

comics.title.[spider.man]

However, if spiderman isn't an object.. and comics is an array of objects, and what you're actually wanting to do is filter for the comic object where the title is spider.man then you probably want to use the jsonpath filter eg 

$.comics.[?(@.title=="spider.man")]

You should also use any online json path evaluator to test the jsonpath expression against your json to see it works as expected.

View solution in original post

2 REPLIES 2

If spider.man is an object, then i think what you want to do is

comics.title.[spider.man]

However, if spiderman isn't an object.. and comics is an array of objects, and what you're actually wanting to do is filter for the comic object where the title is spider.man then you probably want to use the jsonpath filter eg 

$.comics.[?(@.title=="spider.man")]

You should also use any online json path evaluator to test the jsonpath expression against your json to see it works as expected.

maybe show an example payload that you are trying to extract from. 

AFAIK if you have this payload,

 

{
    "comics": {
        "title": {
           "spider.man" : {
              "desc" : "dude gets bitten by radioactive spider, becomes super human"
           }, 
           "super.man" : {
              "desc" : "alien being comes to earth, demonstrates super powers"
           }
       }
    }
}

 

...then you can use something like this in jsonpath:

 

comics['title']['spider.man']