glazejson (glazejson v0.1.1)
View SourceFast JSON encoding and decoding using the glaze C++ library.
By default JSON null is represented as the atom null. To change it
application-wide, set the null env key in your config:
{glazejson, [{null, nil}]}.See also [https://github.com/stephenberry/glaze]
Summary
Functions
Decode a JSON binary or iolist to an Erlang term. JSON objects are returned as maps (default).
Decode a JSON binary or iolist to an Erlang term with options.
Decode a JSON number string to a big integer.
Encode an Erlang term to a JSON binary.
Encode an Erlang term to a JSON binary with options.
Encode a big integer to its JSON string representation.
Minify a JSON binary or iolist, removing all unnecessary whitespace.
Pretty-print a JSON binary or iolist with two-space indentation.
Types
-type decode_opt() :: return_maps | object_as_tuple | use_nil | {null_term, atom()} | {keys, atom | existing_atom | binary}.
-type decode_opts() :: [decode_opt()].
Decode options:
return_maps- decode JSON objects as Erlang maps (default)object_as_tuple- decode JSON objects as{[{K, V}]}proplistsuse_nil- use the atomnilfor JSON null{null_term, Atom}- useAtomfor JSON null{keys, atom}- decode object keys as atoms{keys, existing_atom}- decode keys as existing atoms, fall back to binary{keys, binary}- decode keys as binaries (default)
-type encode_opt() :: pretty | uescape | force_utf8 | use_nil | {null_term, atom()}.
-type encode_opts() :: [encode_opt()].
Encode options:
pretty- pretty-print the JSON outputuescape- escape non-ASCII characters as \uXXXX sequencesforce_utf8- fix invalid UTF-8 sequences before encodinguse_nil- encode the atomnilas JSONnull{null_term, Atom}- encodeAtomas JSONnull
Functions
Decode a JSON binary or iolist to an Erlang term. JSON objects are returned as maps (default).
-spec decode(binary() | iolist(), decode_opts()) -> term().
Decode a JSON binary or iolist to an Erlang term with options.
Decode a JSON number string to a big integer.
Encode an Erlang term to a JSON binary.
-spec encode(term(), encode_opts()) -> binary().
Encode an Erlang term to a JSON binary with options.
Encode a big integer to its JSON string representation.
Minify a JSON binary or iolist, removing all unnecessary whitespace.
Pretty-print a JSON binary or iolist with two-space indentation.