asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://pypi.org/project/RESTinstance
GNU Lesser General Public License v3.0
205 stars 84 forks source link

Library seems unable to parse nested JSON PATH with ? in query #64

Closed technigirl closed 2 years ago

technigirl commented 5 years ago

My code is as follows: ${resp} Output $.data.[?(@.tabLabel=='${label_to_find}')]

The error I get is: Invalid JSONPath query '$.data.[?(@.tabLabel=='Custom Fund Menu')]': Parse error at 1:8 near token ? (?)

The query gets parsed correctly if I remove .data. (so it looks like $[?(@.tabLabel=='Custom Fund Menu')]), but then it doesn't find anything, because it's incorrect for my JSON data. The query as written is correct, and should be parsed by the library.

asimell commented 3 years ago

Hi @technigirl ,

I know this is an old ticket, but it looks like the JSONPath is parsed here, which is an imported method from jsonpath-ng. I think (without testing) that this is an issue related to that library, but I'd need to be sure it's caused from that.

asimell commented 2 years ago

@technigirl Coming back to this. It looks like your original JSONPath is an invalid JSONPath. The correct format should be $.data[?(@.tabLabel=='${label_to_find}')] (without the extra . between data and [). Can you try if that works?

asimell commented 2 years ago

Not enough info, so closing issue. Please reopen if this is still a problem.