Copyright © (C) 2020, Jan Henry Nystrom <JanHenryNystrom@gmail.com> -------------------------------------------------------------------
Authors: Jan Henry Nystrom (JanHenryNystrom@gmail.com).
A JSON stream library based on: The JavaScript Object Notation (JSON) Data Interchange Format (rfc7159)
JSON is represented as follows:
value : true | false | null | object | array | number | string
object : map array : [value*] string : UTF-8 binary number : integer() | float() true : atom(true) false : atom(false) null : atom(null)
Strings can be represented by atoms when generating JSON, but will not not be generated when converting JSON to erlang. Strings are restricted to UTF-8
When converting Erlang terms to JSON iolists are generated but it can generate a binary if so instructed.
Objects as maps, multiple occurrences of the members is not supported.array() = [json()]
complete() = boolean()
cont() = {decode, stack()} | {object, {complete(), expect()}, acc(), stack()} | {array, {first(), complete()}, array(), stack()} | {string, binary(), stack()} | {unescape, binary(), stack()} | {number, stage(), phase(), list(), stack()}
expect() = name | comma | colon
first() = boolean()
json() = true | false | null | number() | jstring() | object() | array()
jstring() = binary()
name() = jstring()
object() = map()
phase() = int | float | exp
stack() = [{array, array()} | {name, acc()} | {value, {name(), acc()}}]
stage() = sign | zero | pre | post
decode/1 | Decodes the binary into a tuple of structured Erlang term and the remaining binary or a continuation if the binary did not contain a complete JSON value. |
decode/2 | Decodes a binary and a continuation into a tuple of structured Erlang term and the remaining binary or a continuation if the binary did not contain a complete JSON value. |
encode/1 | Encodes the structured Erlang term as an iolist. |
encode/2 | Encodes the structured Erlang term as an iolist or binary. |
Decodes the binary into a tuple of structured Erlang term and the remaining binary or a continuation if the binary did not contain a complete JSON value. The continuation can be used by decode/2 with a binary containing the rest of the JSON value to decode.
Decodes a binary and a continuation into a tuple of structured Erlang term and the remaining binary or a continuation if the binary did not contain a complete JSON value. The continuation can be used with a binary containing the rest of the JSON value to decode.
encode(Object::json()) -> iodata()
Encodes the structured Erlang term as an iolist. Equivalent of encode(Term, iolist) -> JSON.
encode(V::json(), X2::binary) -> binary()
Encodes the structured Erlang term as an iolist or binary. Encode will give an exception if the erlang term is not well formed. Options are: binary -> a binary is returned iolist -> an iolist is returned (default)
Generated by EDoc