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
Link to this section Types
Link to this type
filter()
View Sourcefilter() :: {:filter, has_property() | {operator() | guard(), term()}}
Link to this type
guard()
View Sourceguard() :: :is_atom | :is_binary | :is_boolean | :is_float | :is_integer | :is_list | :is_map | :is_nil | :is_number | :is_tuple
Link to this type
operator()
View Sourceoperator() :: :< | :> | :<= | :>= | :== | :!= | :=== | :!== | :not | :and | :or | :in
Link to this type
slice()
View Sourceslice() :: {:slice, [start_index: integer(), end_index: integer(), step: non_neg_integer()]}
Link to this type
token()
View Sourcetoken() :: root() | indexes() | slice() | dot_access() | filter() | scan() | union_property() | wildcard()
Link to this section Functions
Link to this function
compile(expression)
View Sourcecompile(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, only: [sigil_q: 2]
iex> ~q"$.post.author"
%Warpath.Expression{tokens: [ {:root, "$"}, {:dot, {:property, "post"}}, {:dot, {:property, "author"}} ]}