Jaxon v2.0.0-alpha.2 Jaxon.Parser behaviour View Source

Example

Call parse/1 get a list of parsed events:

Note that keys are treated as the same as strings

iex> Jaxon.Parser.parse("{\"jaxon\":\"rocks\",\"array\":[1,2]}")
{:ok, [
 :start_object,
 {:string, "jaxon"},
 :colon,
 {:string, "rocks"},
 :comma,
 {:string, "array"},
 :colon,
 :start_array,
 {:integer, 1},
 :comma,
 {:integer, 2},
 :end_array,
 :end_object
]}
iex> Jaxon.Parser.parse(~s(2, 3  true null "incomplete string))
{:incomplete, [
 {:integer, 2},
 :comma,
 {:integer, 3},
 {:boolean, true},
  nil,
], "\"incomplete string"}

Link to this section Summary

Link to this section Types

Link to this type

parse_return()

View Source
parse_return() ::
  {:ok, [Jaxon.Event.t()]}
  | {:error, Jaxon.ParseError.t()}
  | {:incomplete, [Jaxon.Event.t()], String.t()}

Link to this section Functions

Link to this function

parse(events, opts \\ [])

View Source
parse(String.t(), Keyword.t()) :: parse_return()

Link to this section Callbacks