2

I'd like to programmatically compare two JSONPaths, preferably using the Python library jsonpath_ng as it is already used by the project.

I need to be able to tell for example, whether the item pointed to by this JSONPath:

"$.top.middle[0].bottom[0].START"

Will also be pointed to by this one with wildcards:

"$.top.middle[*].bottom[*].START"

I can bodge this simply by replacing numbers with *, but that won't account for any other JSONPath features might be used in the future. So I'd like to use some feature of a jsonpath-compatible library like jsonpath_ng to do this properly.

James Bradbury
  • 1,708
  • 1
  • 19
  • 31
  • This looks like an example of an "inclusion problem". There's a good post [here](https://stackoverflow.com/a/18864555) in the context of regexes. – Graham Parsons Oct 08 '21 at 08:41
  • I am not sure if `jsonpath-ng` has any `JSONPath options` to output the path instead of values. You can get all the possible output path of the wildcard expression and check if the one with hardcoded index is one among them. Check https://jsonpath.com/ and click on the checkbox `Output paths` or Check https://jsonpath.herokuapp.com/ and click on the checkbox `Normalized path expressions`. – Akshay G Oct 18 '21 at 07:48

0 Answers0