exjsonpath v0.9.0 ExJSONPath
This module implements a JSONPath evaluator.
Link to this section Summary
Link to this section Types
Link to this section Functions
Link to this function
compile(path)
compile(String.t()) :: {:ok, compiled_path()} | {:error, ExJSONPath.ParsingError.t()}
Parse and compile a path.
Returns a {:ok, compiled_path} on success, {:error, reason} otherwise.
Link to this function
eval(input, jsonpath)
eval(term(), String.t() | compiled_path()) :: {:ok, [term()]} | {:error, ExJSONPath.ParsingError.t()}
Evaluate JSONPath on given input.
Returns {:ok, [result1 | results]} on success, {:error, %ExJSONPath.ParsingError{}} otherwise.
Examples
iex> ExJSONPath.eval(%{"a" => %{"b" => 42}}, "$.a.b")
iex> ExJSONPath.eval([%{"v" => 1}, %{"v" => 2}, %{"v" => 3}], "$[?(@.v > 1)].v")
iex> ExJSONPath.eval(%{"a" => %{"b" => 42}}, "$.x.y")