Jaxon v0.1.1 Jaxon View Source
Example
Create a new decoder and add your JSON data:
decoder =
Jaxon.make_decoder()
|> Jaxon.update_decoder("{\"jaxon\":\"rocks\",\"array\":[1,2]}")
Call decode/1
on the decoder to consume the events one by one:
iex> decoder = Jaxon.make_decoder() |> Jaxon.update_decoder("{\"jaxon\":\"rocks\",\"array\":[1,2]}")
iex> Jaxon.decode(decoder)
:start_object
Or call consume/1
to read all the events in a list:
iex> decoder = Jaxon.make_decoder() |> Jaxon.update_decoder("{\"jaxon\":\"rocks\",\"array\":[1,2]}")
iex> Jaxon.consume(decoder)
[
:start_object,
{:key, "jaxon"},
{:string, "rocks"},
{:key, "array"},
:start_array,
{:integer, 1},
{:integer, 2},
:end_array,
:end_object,
:end
]
Link to this section Summary
Functions
Helper function that calls decode/1
until there are no more events
Get a single event from the decoder, must call update_decoder/2
with your data beforehand
Link to this section Types
Link to this section Functions
Helper function that calls decode/1
until there are no more events.
Example
iex> Jaxon.make_decoder() |> Jaxon.update_decoder(“{\”jaxon\”:\”rocks\”}”) |> Jaxon.consume() [:start_object, {:key, “jaxon”}, {:string, “rocks”}, :end_object, :end]
Get a single event from the decoder, must call update_decoder/2
with your data beforehand.
Example
iex> Jaxon.make_decoder() |> Jaxon.update_decoder(“{\”jaxon\”:\”rocks\”}”) |> Jaxon.decode() :start_object