These functions both read and transform JSON data into Erlang types.
The main reading functions return {ok, {Value, Rest}}
or {error, Atom}
.
jsonpull_read
module, so they also skip
whitespace.
null/1 | Try to read a null from the JSON. |
boolean/1 | Try to read a boolean from the JSON. |
string/1 | Try to read a string from the JSON. |
iolist/1 | Try to read a string from the JSON as an iolist. |
existing_atom/1 | Try to read a string from the JSON as an already existing atom. |
number/1 | Try to read a number from the JSON. |
integer/1 | Try to read an integer from the JSON. |
float/1 | Try to read a float from the JSON. |
array/1 | Try to read an array from the JSON. |
element/1 | Try to read the next array element from the JSON. |
object/1 | Try to read an object from the JSON. |
key/1 | Try to read the next object key from the JSON. |
unescape_and_strip/1 | Turn a raw JSON string into a properly translated Erlang iolist. |
strip/1 | Strips the quotes from a raw JSON string. |
skip_value/1 | Skips over the next value in the provided JSON binary. |
null(JSON::binary()) -> {ok, {Value::null, Rest::binary()}} | {error, not_null}
Try to read a null from the JSON.
If it's there, it will be returned as the atom 'null'
.
boolean(JSON::binary()) -> {ok, {Value::boolean(), Rest::binary()}} | {error, not_boolean}
Try to read a boolean from the JSON.
If it's there, it will be returned as the atom 'true'
or 'false'
.
string(JSON::binary()) -> {ok, {Value::binary(), Rest::binary()}} | {error, not_string | unterminated_string | invalid_escape_sequence}
Try to read a string from the JSON. If it's there, it will be returned as a binary string with all escape sequences processed.
See also: iolist/1.
iolist(JSON::binary()) -> {ok, {Value::iolist(), Rest::binary()}} | {error, not_string | unterminated_string | invalid_escape_sequence}
Try to read a string from the JSON as an iolist. This is like reading a string, except escape sequences are handled differently.
This may be more efficient in some cases.See also: string/1.
existing_atom(JSON::binary()) -> {ok, {Value::atom(), Rest::binary()}} | {error, not_string | unterminated_string | not_existing_atom}
Try to read a string from the JSON as an already existing atom. This function will not parse escape sequences.
See also: string/1.
number(JSON::binary()) -> {ok, {Value::binary(), Rest::binary()}} | {error, not_number}
Try to read a number from the JSON. If it's there, it will be returned as the original binary string version.
integer(JSON::binary()) -> {ok, {Value::integer(), Rest::binary()}} | {error, not_integer}
Try to read an integer from the JSON. This function will discriminate against floats and only return integers.
float(JSON::binary()) -> {ok, {Value::float(), Rest::binary()}} | {error, not_float}
Try to read a float from the JSON. This function will discriminate against integers and only return floats.
See also: integer/1, number/1.
array(JSON::binary()) -> {ok, {begin_array, Rest::binary()}} | {error, not_array}
Try to read an array from the JSON.
If it's there, the atom 'begin_array'
will be returned.
element(JSON::binary()) -> {ok, {element, Rest::binary()}} | {ok, {end_array, Rest::binary()}}
Try to read the next array element from the JSON.
If there is an element, it will be represented as the atom 'element'
If the array is ending, the atom 'end_array'
will be returned.
object(JSON::binary()) -> {ok, {begin_object, Rest::binary()}} | {error, not_object}
Try to read an object from the JSON.
If there is an object, the atom 'begin_object'
will be returned.
key(JSON::binary()) -> {ok, {Key::binary(), Rest::binary()}} | {ok, {end_object, Rest::binary()}} | {error, missing_colon_after_key | unterminated_key | key_not_string | unterminated_string | invalid_escape_sequence}
Try to read the next object key from the JSON. If there is a key, it will be returned as a binary string.
If the object is ending, the atom 'end_object'
will be returned.
unescape_and_strip(String::binary()) -> {ok, iolist()} | unterminated_string | invalid_escape_sequence
Turn a raw JSON string into a properly translated Erlang iolist.
Note: You may need to use unicode:characters_to_binary/list afterwards if you don't want an iolist.
Using iolist_to_binary will only work if there are no weird unicode escape sequences!strip(X1) -> any()
Strips the quotes from a raw JSON string.
See also: unescape_and_strip/1.
skip_value(JSONIn::binary()) -> JSONOut::binary() | {error, atom()}
Skips over the next value in the provided JSON binary.
Generated by EDoc