z_json (zotonic_core v1.0.0-rc.17)

JSON support routines.

Summary

Functions

Decode a JSON binary to an Erlang term.

Encode an Erlang term to JSON. Ensure all '/' characters in the JSON are escaped for save embedding the generated JSON in HTML text.

JSON escape for safe quoting of JSON strings. Subtly different from JS escape, see http://www.json.org/

Functions

decode(Json)

-spec decode(binary() | undefined) -> term().

Decode a JSON binary to an Erlang term.

encode(Erlang)

-spec encode(binary() | map() | list() | undefined) -> binary().

Encode an Erlang term to JSON. Ensure all '/' characters in the JSON are escaped for save embedding the generated JSON in HTML text.

json_escape(Value)

-spec json_escape(iodata() | undefined) -> iodata().

JSON escape for safe quoting of JSON strings. Subtly different from JS escape, see http://www.json.org/