exjsonpath

JSONPath library for Elixir


Keywords
elixir, elixir-library, json, jsonpath
License
Apache-2.0

Documentation

ExJsonPath

ExJsonPath is an Elixir library which allows to query maps (JSON objects) and lists (JSON arrays), using JSONPath expressions.

ExJsonPath is not limited to JSON, but allows to query nearly any kind of map or list, with just one main restriction: keys have to be strings.

Installation

  • Add ExJsonPath dependency to your project's mix.exs:
def deps do
  [
    {:exjsonpath, "~> 0.1"}
  ]
end
  • Run mix deps.get

Basic Usage

iex(1)> ExJsonPath.eval([%{"v" => 1}, %{"v" => 2}, %{"v" => 3}], "$[?(@.v > 1)].v")
{:ok, [2, 3]}
iex(1)> {:ok, json} = File.read("store.json")
iex(2)> {:ok, store} = Jason.decode(json)
iex(3)> ExJsonPath.eval(store, "$.store.book[?(@.price > 20)].title")
{:ok, ["The Lord of the Rings"]}

Full documentation can be found at hexdocs.pm/exjsonpath.

About This Project

This project has been created in order to provide support to JSONPath to Astarte Flow. We are open to any contribution and we encourage adoption of this library to anyone looking for a maps and lists query language.