Warpath v0.3.0-rc.2 Warpath.Element.Path View Source

This module contains functions to accumulate and transform item path tokens.

The path are built during a expression evaluation by Warpath.query/3.

Link to this section Summary

Functions

Accumulate a path token into a path acc.

Transform path tokens into a jsonpath bracket-notation representation.

Transform path tokens into a jsonpath dot-notation representation.

Link to this section Types

Link to this type

acc()

View Source
acc() :: [token(), ...] | []
Link to this type

token()

View Source
token() ::
  {:root, String.t()}
  | {:property, String.t() | atom()}
  | {:index_access, integer()}

Link to this section Functions

Link to this function

accumulate(token, acc)

View Source
accumulate(token(), acc()) :: acc()

Accumulate a path token into a path acc.

Example

iex> acc = [{:root, "$"}]
...> Warpath.Element.Path.accumulate({:property, "name"}, acc)
[{:property, "name"}, {:root, "$"}]
Link to this function

bracketify(paths)

View Source
bracketify(acc()) :: binary()

Transform path tokens into a jsonpath bracket-notation representation.

Example

iex> acc = [{:property, "name"}, {:root, "$"}]
...> Warpath.Element.Path.bracketify(acc)
"$['name']"
Link to this function

dotify(paths)

View Source
dotify(acc()) :: binary()

Transform path tokens into a jsonpath dot-notation representation.

Example

iex> acc = [{:property, "name"}, {:root, "$"}]
...> Warpath.Element.Path.dotify(acc)
"$.name"