Module jsonpull_read

These are the most basic functions you can use to read data from JSON.

Description

These are the most basic functions you can use to read data from JSON. They take the value you ask for out of binary JSON if it's there. They return {Bin, Rest} or an atom representing an error. They will also skip whitespace.

For more information on how to use these functions and what a pull parser is, read the Overview.

Function Index

null/1Try to read a null from the JSON.
boolean/1Try to read a boolean from the JSON.
string/1Try to read a string from the JSON.
number/1Try to read a number from the JSON.
array/1Try to read an array from the JSON.
element/1Try to read the next array element from the JSON.
object/1Try to read an object from the JSON.
key/1Try to read the next object key from the JSON.

Function Details

null/1

null(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_null

Try to read a null from the JSON. If it's there, it will be returned as a binary <<"null">>.

boolean/1

boolean(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_boolean

Try to read a boolean from the JSON. If it's there, it will be returned as a binary <<"true">> or <<"false">>.

string/1

string(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_string | unterminated_string

Try to read a string from the JSON. If it's there, it will be returned without any sort of processing. This means escape sequences and the quotation marks on the edges are still there.

See also: jsonpull:unescape_and_strip/1.

number/1

number(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_number

Try to read a number from the JSON. If it's there, it will be returned as a binary string in its original form.

array/1

array(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_array

Try to read an array from the JSON. If an array is starting here, the binary <<"[">> will be returned.

Structured types are handled differently in pull parsers. For more info, read the Overview.

element/1

element(JSON::binary()) -> {ReadValue::binary(), Rest::binary()}

Try to read the next array element from the JSON. If there is an element, either the binary <<",">> or an empty binary will be returned.

If the array is ending, the binary <<"]">> will be returned.

Structured types are handled differently in pull parsers. For more info, read the Overview.

object/1

object(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | not_object

Try to read an object from the JSON. If there is an object, the binary <<"{">> will be returned.

Structured types are handled differently in pull parsers. For more info, read the Overview.

key/1

key(JSON::binary()) -> {ReadValue::binary(), Rest::binary()} | missing_colon_after_key | unterminated_key | key_not_string

Try to read the next object key from the JSON. If there is a key, it will be returned as a raw string, with the same caveats as string/1.

If the object is ending, the binary <<"}">> will be returned.

Structured types are handled differently in pull parsers. For more info, read the Overview.


Generated by EDoc