Jaxon.Stream (Jaxon v2.0.8) View Source

Link to this section Summary

Functions

Transform a binary stream into a stream of events.

Query all values of an array

Link to this section Types

Specs

event_stream() :: Enumerable.t()

Specs

term_stream() :: Enumerable.t()

Link to this section Functions

Specs

from_binary(String.t()) :: event_stream() | no_return()
Link to this function

from_enumerable(bin_stream)

View Source

Specs

from_enumerable(Enumerable.t()) :: event_stream()

Transform a binary stream into a stream of events.

iex(1)> Jaxon.Stream.from_enumerable([~s({"jaxon"), ~s(:"rocks","array":[1,2]})]) |> Enum.take(1)
[[:start_object, {:string, "jaxon"}]]
Link to this function

query(event_stream, query)

View Source

Specs

Query all values of an array:

iex> ~s({ "numbers": [1,2] })
...> |> Jaxon.Stream.from_binary()
...> |> Jaxon.Stream.query([:root, "numbers", :all])
...> |> Enum.to_list()
[1, 2]

Query an object property:

iex> ~s({ "person": {"name": "Jose"} })
...> |> Jaxon.Stream.from_binary()
...> |> Jaxon.Stream.query([:root, "person", "name"])
...> |> Enum.to_list()
["Jose"]

Specs

values(event_stream()) :: term_stream()

See Jaxon.Decoders.Values.values/1.