From e18322779e74300b0ed9b46e630ba2fb164f9fcd Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sat, 12 May 2012 23:28:48 +0000 Subject: [PATCH] add prettify/1 and minify/1 --- src/jsx.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/jsx.erl b/src/jsx.erl index 78dc409..ba32b01 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -26,7 +26,7 @@ -export([to_json/1, to_json/2]). -export([to_term/1, to_term/2]). -export([is_json/1, is_json/2, is_term/1, is_term/2]). --export([format/1, format/2]). +-export([format/1, format/2, minify/1, prettify/1]). -export([encoder/3, decoder/3]). %% old api -export([term_to_json/1, term_to_json/2, json_to_term/1, json_to_term/2]). @@ -60,6 +60,16 @@ format(Source) -> format(Source, []). format(Source, Opts) -> jsx_to_json:format(Source, Opts). +-spec minify(Source::binary()) -> binary(). + +minify(Source) -> format(Source, []). + + +-spec prettify(Source::binary()) -> binary(). + +prettify(Source) -> format(Source, [space, {indent, 2}]). + + -spec to_term(Source::binary()) -> list({binary(), any()}) | list(any()) | true