Search code examples
jsonpath

Why does JSONPath not support parent?


JSONPath seems to be a popular syntax to get XPath-like searching inside JSON data. And it has been repeatedly asked whether JSONPath supports navigation to a parent (see here and here).

My question is whether there is a good reason why it has not been suggested from the start, even though it is explicitly mentioned as unsupported. Is there some syntactic reason from JavaScript? Or is there some general workaround that I am missing?


Solution

  • This specification was written up on a blog; AFAIK, it is not part of any ongoing committee standardization.

    However, to meet the need for parent accessors (and other features), at least one implementation, JSONPath-plus which is a superset of the original spec, allows for accessing parents through a number of means (see the README docs).

    Disclaimer: I am involved in working on this implementation.