h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
582 stars 85 forks source link

Added a `path` extension that exposes datum's path from the jsonpath itself #176

Closed dlastov closed 1 month ago

dlastov commented 1 month ago

Obviously this extension does not have much meaning for a developer who uses jsonpath in his python code and can call simply 'datum.path'.

However it opens possibilities for new use cases where a python-written application implements a service that exposes jsonpaths to the user.

As a particular example, consider XPath expressions (with their name() function) in XSLT template. Similarly, someone could write a templating system that uses jsonpath.

<template match="$">
    <for-each select="*">Object <value-of select="@.`path`"/> has value <value-of select="@"/></for-each>
<template>
michaelmior commented 1 month ago

Thanks @dlastov!