Code Monkey home page Code Monkey logo

jpath's Introduction

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 syntax by Stefan Goessner. If you prefer the latter, there's a terrific library 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.

jpath's People

Contributors

serebryakov avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.