Diff: [root] @ 9606cfcf7d0 | faq | css

hjpath news

File: code/hjpath [Diff]

-- a/code/hjpath++ b/code/hjpath
@@ -9,6 +9,18 @@
* * wildcard, matches any object or array element: @/someobject/*/anotherarray/*@
* ==** wildcard==, acts like "//" in XPath, matches any sequence of elements. @**/something@

h2. How to use

You can search within any type that is an instance of HJsonLike. Out-of box it works with *String*s and HJson. Results will be in the same format.

bc. jPath "[2]" "[1,2,3]" -- ["3"]
jPath "wtf" "{\"wtf\": 3}" -- ["3"]
jPath "[2]" $ JArray [JNull, JNumber 1, JNumber 2] -- [JNumber (2 % 1)]

Since 3.0, you can also avoid string queries and compose them using Haskell:

bc. jPath [ArrayLookup 2] "[1,2,3]" -- ["3"]

h2. Get it

* With "cabal-install":http://www.haskell.org/cabal/download.html: cabal install hjpath

By Voker57 on 2010-05-30 14:52:57 +0000