Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdegrunt/jpath
JPath is a Ruby library that allows to execute XPath queries on JSON documents
https://github.com/tdegrunt/jpath
Last synced: 26 days ago
JSON representation
JPath is a Ruby library that allows to execute XPath queries on JSON documents
- Host: GitHub
- URL: https://github.com/tdegrunt/jpath
- Owner: tdegrunt
- License: mit
- Created: 2018-03-23T19:29:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2014-05-12T17:13:51.000Z (over 10 years ago)
- Last Synced: 2024-10-07T17:35:16.502Z (about 1 month ago)
- Language: Ruby
- Size: 117 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JPath
JPath is a Ruby library that allows to execute XPath queries on JSON documents.
### Installation
JPath doesn't use any dependencies. Simply install via rubygems:
gem install jpath
or clone it from github:
git clone https://github.com/merimond/jpath.git
JPath is in early beta stage. So having an up-to-date Git version is more preferable.
## Library
Please note that JPath works with *standard* XPath syntax, not one of XPath alternatives, such as the great [JSONPath](http://goessner.net/articles/JsonPath/) syntax by Stefan Goessner. If you prefer the latter, there's a [terrific library](https://github.com/joshbuddy/jsonpath) by Joshua Hull that you should check out.
### A few caveats
Although JSON and XML are both data containers, they are quite different when it comes to searching and manipulating data. So JPath _may_ behave somewhat differently from what you woud expect, although we tried to make some sensible assumptions while transforming the XML-oriented search paradigm into the JSON world.
## Features
JPath support all the basic and some of the more advanced XPath functions:
Simple chains with children and ancestors:
/store/book/author
//author
/store/*
Position predicates://book[last()]
//book[position()<3]Attribute and child predicates:
//book[@price<10]
//book[isbn]Multiple predicates:
//book[@price>10][last()]
And all of the above in non-abbreviated form:
/descendant::book
/child::book[attribute::price="8.95"]Test files are a bit of a mess at the moment, but they should give you an indication of what's currently supported.
## Contributing
Fork, send pull requests, file bug reports -- any help is welcome.