From fe67eb5b266d9e2f6e218856f283dd61113760fa Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sat, 22 Dec 2012 11:01:34 -0800 Subject: [PATCH 1/2] Update src/jsx.erl minor formatting changes --- src/jsx.erl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/jsx.erl b/src/jsx.erl index 6bfec15..7285566 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -56,7 +56,6 @@ -spec encode(Source::json_term(), Opts::jsx_to_json:opts()) -> json_text(). encode(Source) -> encode(Source, []). - encode(Source, Opts) -> jsx_to_json:to_json(Source, Opts). %% old api, alias for encode/x @@ -71,7 +70,6 @@ term_to_json(Source, Opts) -> encode(Source, Opts). -spec format(Source::json_text(), Opts::jsx_to_json:opts()) -> json_text(). format(Source) -> format(Source, []). - format(Source, Opts) -> jsx_to_json:format(Source, Opts). @@ -89,7 +87,6 @@ prettify(Source) -> format(Source, [space, {indent, 2}]). -spec decode(Source::json_text(), Opts::jsx_to_term:opts()) -> json_term(). decode(Source) -> decode(Source, []). - decode(Source, Opts) -> jsx_to_term:to_term(Source, Opts). %% old api, alias for to_term/x @@ -104,7 +101,6 @@ json_to_term(Source, Opts) -> decode(Source, Opts). -spec is_json(Source::any(), Opts::jsx_verify:opts()) -> true | false. is_json(Source) -> is_json(Source, []). - is_json(Source, Opts) -> jsx_verify:is_json(Source, Opts). @@ -112,7 +108,6 @@ is_json(Source, Opts) -> jsx_verify:is_json(Source, Opts). -spec is_term(Source::any(), Opts::jsx_verify:opts()) -> true | false. is_term(Source) -> is_term(Source, []). - is_term(Source, Opts) -> jsx_verify:is_term(Source, Opts). From 21011964daabe7b92118a803add41afbe9b92f64 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Tue, 22 Jan 2013 12:41:56 -0800 Subject: [PATCH 2/2] add `{incomplete, ...}` to return types of core jsx functions `encode`, `decode`, `format`, `prettify` and `minify` were incompletely specified closes #27 --- src/jsx.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jsx.erl b/src/jsx.erl index 7285566..b4eb526 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -52,8 +52,8 @@ -type json_text() :: binary(). --spec encode(Source::json_term()) -> json_text(). --spec encode(Source::json_term(), Opts::jsx_to_json:opts()) -> json_text(). +-spec encode(Source::json_term()) -> json_text() | {incomplete, encoder()}. +-spec encode(Source::json_term(), Opts::jsx_to_json:opts()) -> json_text() | {incomplete, encoder()}. encode(Source) -> encode(Source, []). encode(Source, Opts) -> jsx_to_json:to_json(Source, Opts). @@ -66,25 +66,25 @@ term_to_json(Source) -> encode(Source, []). term_to_json(Source, Opts) -> encode(Source, Opts). --spec format(Source::json_text()) -> json_text(). --spec format(Source::json_text(), Opts::jsx_to_json:opts()) -> json_text(). +-spec format(Source::json_text()) -> json_text() | {incomplete, decoder()}. +-spec format(Source::json_text(), Opts::jsx_to_json:opts()) -> json_text() | {incomplete, decoder()}. format(Source) -> format(Source, []). format(Source, Opts) -> jsx_to_json:format(Source, Opts). --spec minify(Source::json_text()) -> json_text(). +-spec minify(Source::json_text()) -> json_text() | {incomplete, decoder()}. minify(Source) -> format(Source, []). --spec prettify(Source::json_text()) -> json_text(). +-spec prettify(Source::json_text()) -> json_text() | {incomplete, decoder()}. prettify(Source) -> format(Source, [space, {indent, 2}]). --spec decode(Source::json_text()) -> json_term(). --spec decode(Source::json_text(), Opts::jsx_to_term:opts()) -> json_term(). +-spec decode(Source::json_text()) -> json_term() | {incomplete, decoder()}. +-spec decode(Source::json_text(), Opts::jsx_to_term:opts()) -> json_term() | {incomplete, decoder()}. decode(Source) -> decode(Source, []). decode(Source, Opts) -> jsx_to_term:to_term(Source, Opts).