Skip to content

taimoorzaeem/aeson-jsonpath

Repository files navigation

aeson-jsonpath

ci-badge hackage-docs

Run RFC 9535 compliant JSONPath queries on Data.Aeson.

Roadmap

  • Selectors
    • Name Selector
    • Index Selector
    • Slice Selector
    • Wildcard Selector
    • Filter Selector
  • Segments
    • Child Segment
    • Descendant Segment
  • Function Extensions
  • Setting Values (Non-RFC)

Why use this?

  • Provides a clean interface (single function call) to run RFC 9535 compliant JSONPath queries on Data.Aeson objects.
  • The parser is written in an extendable way and hence it will be able to provide newer features in our future releases possibly without any breaking changes.
{-# LANGUAGE QuasiQuotes #-}
import Data.Aeson          (Value (..))
import Data.Aeson.JSONPath (runJSPQuery, jsonPath)

jsonDoc :: Value -- aeson value

-- usage example
runJSPQuery [jsonPath|$|] jsonDoc
runJSPQuery [jsonPath|$.*|] jsonDoc
runJSPQuery [jsonPath|$..*|] jsonDoc
runJSPQuery [jsonPath|$.store|] jsonDoc
runJSPQuery [jsonPath|$.store.books|] jsonDoc
runJSPQuery [jsonPath|$.store.books[0]|] jsonDoc
runJSPQuery [jsonPath|$.store.books[-4]|] jsonDoc
runJSPQuery [jsonPath|$.store.books[1:4:-1]|] jsonDoc
runJSPQuery [jsonPath|$.store.books[1,2:5,7]|] jsonDoc

Development

Please report any bugs you encounter by opening an issue. Contributions are welcomed.