/JPath

A JSON parser in Python using xpath-like strings, but for JSON data

Primary LanguagePython

JPath

This parser can be used to manage JSON data, by performing get, set operations
on it using JPath queries. These Jpath queries look very similar to Xpath
queries and carries over many of the similar syntactic goodies, such as
defining predicates to fetch nodes with a certain value: [1] or [2] to fetch
the first or second element respectively, or [@foo=bar] which fetches a node
whose attribute called "foo" has the value "bar". To iterate over large data
sets and perform get or set operations over each iter-element, IterItems()
can be used, with the only constraint that the provided Jpath query has
an iterable token "[*]", otherwise a QueryError is raised. Other syntactic
goodies will be added as this library matures.