Warpath.Expression (Warpath v0.5.0) View Source
This module contains functions to compile a jsonpath query string.
Link to this section Summary
Link to this section Types
Specs
dot_access() :: {:dot, property()}
Specs
filter() :: {:filter, has_children() | {operator() | guard(), subpath_expression() | term()}}
Specs
guard() :: :is_atom | :is_binary | :is_boolean | :is_float | :is_integer | :is_list | :is_map | :is_nil | :is_number | :is_tuple
Specs
has_children() :: {:has_children?, subpath_expression()}
Specs
indexes() :: {:indexes, [{:index_access, integer()}, ...]}
Specs
operator() :: :< | :> | :<= | :>= | :== | :!= | :=== | :!== | :not | :and | :or | :in
Specs
Specs
root() :: {:root, String.t()}
Specs
Specs
slice() :: {:slice, [start_index: integer(), end_index: integer(), step: non_neg_integer()]}
Specs
subpath_expression() :: {:subpath_expression, keyword()}
Specs
t() :: %Warpath.Expression{tokens: [token(), ...]}
Specs
token() :: root() | indexes() | slice() | dot_access() | filter() | scan() | union_property() | wildcard()
Specs
union_property() :: {:union, [dot_access(), ...]}
Specs
wildcard() :: {:wildcard, :*}
Link to this section Functions
Specs
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"}} ]}}
Compiles jsonpath string query to expression.
Examples
iex> import Warpath.Expression
iex> ~q"$.post.author"
%Warpath.Expression{tokens: [ {:root, "$"}, {:dot, {:property, "post"}}, {:dot, {:property, "author"}} ]}