View Source jsonpull_read (jsonpull v0.1.1)
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.Summary
Functions
Try to read an array from the JSON. If an array is starting here, the binary <<"[">>
will be returned.
<<"true">>
or <<"false">>
.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.
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
.
<<"null">>
.Try to read an object from the JSON. If there is an object, the binary <<"{">>
will be returned.
See also: jsonpull:unescape_and_strip/1.
Functions
-spec 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.
-spec boolean(JSON :: binary()) -> {ReadValue :: binary(), Rest :: binary()} | not_boolean.
<<"true">>
or <<"false">>
.
-spec 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.
-spec 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.
-spec null(JSON :: binary()) -> {ReadValue :: binary(), Rest :: binary()} | not_null.
<<"null">>
.
-spec number(JSON :: binary()) -> {ReadValue :: binary(), Rest :: binary()} | not_number.
-spec 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.
-spec string(JSON :: binary()) ->
{ReadValue :: binary(), Rest :: binary()} | not_string | unterminated_string.
See also: jsonpull:unescape_and_strip/1.