Warpath v0.3.0-rc.2 Warpath.Expression View Source

This module contains functions to compile a jsonpath query string.

Link to this section Summary

Functions

Compile a jsonpath string query

Compiles jsonpath string query to expression.

Link to this section Types

Link to this type

dot_access()

View Source
dot_access() :: {:dot, property()}
Link to this type

filter()

View Source
filter() :: {:filter, has_property() | {operator() | guard(), term()}}
Link to this type

guard()

View Source
guard() ::
  :is_atom
  | :is_binary
  | :is_boolean
  | :is_float
  | :is_integer
  | :is_list
  | :is_map
  | :is_nil
  | :is_number
  | :is_tuple
Link to this type

has_property()

View Source
has_property() :: {:has_property?, property()}
Link to this type

indexes()

View Source
indexes() :: {:indexes, [{:index_access, integer()}, ...]}
Link to this type

operator()

View Source
operator() ::
  :< | :> | :<= | :>= | :== | :!= | :=== | :!== | :not | :and | :or | :in
Link to this type

property()

View Source
property() :: {:property, String.t() | atom()}
Link to this type

root()

View Source
root() :: {:root, String.t()}
Link to this type

scan()

View Source
scan() :: {:scan, property() | wildcard() | filter() | indexes()}
Link to this type

slice()

View Source
slice() ::
  {:slice,
   [start_index: integer(), end_index: integer(), step: non_neg_integer()]}
Link to this type

t()

View Source
t() :: %Warpath.Expression{tokens: [token(), ...]}
Link to this type

union_property()

View Source
union_property() :: {:union, [dot_access(), ...]}
Link to this type

wildcard()

View Source
wildcard() :: {:wildcard, :*}

Link to this section Functions

Link to this function

compile(expression)

View Source
compile(String.t()) :: {:ok, t()} | {:error, Warpath.ExpressionError.t()}

Compile a jsonpath string query

Example

iex> Warpath.Expression.compile("$.post.author")
{:ok, %Warpath.Expression{tokens: [ {:root, "$"}, {:dot, {:property, "post"}}, {:dot, {:property, "author"}} ]}}
Link to this macro

sigil_q(arg, modifiers)

View Source (macro)

Compiles jsonpath string query to expression.

Examples

iex> import Warpath.Expression, only: [sigil_q: 2]
iex> ~q"$.post.author"
%Warpath.Expression{tokens: [ {:root, "$"}, {:dot, {:property, "post"}}, {:dot, {:property, "author"}} ]}