From 922e3e525e725312e8f5cc2214513def77605970 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Mon, 4 Jul 2011 21:04:10 -0700 Subject: [PATCH] removed now meaningless strict option from format and verify modules and associated types and specs --- src/jsx_common.hrl | 6 ++---- src/jsx_format.hrl | 3 +-- src/jsx_verify.erl | 22 +++++----------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/jsx_common.hrl b/src/jsx_common.hrl index 07a7c98..c73dda0 100644 --- a/src/jsx_common.hrl +++ b/src/jsx_common.hrl @@ -123,13 +123,11 @@ -type verify_opts() :: [verify_opt()]. --type verify_opt() :: {strict, true | false} - | {encoding, auto | supported_utf()}. +-type verify_opt() :: {encoding, auto | supported_utf()}. -type format_opts() :: [format_opt()]. --type format_opt() :: {strict, true | false} - | {encoding, auto | supported_utf()} +-type format_opt() :: {encoding, auto | supported_utf()} | {space, integer()} | space | {indent, integer()} diff --git a/src/jsx_format.hrl b/src/jsx_format.hrl index 562c52a..689ff23 100644 --- a/src/jsx_format.hrl +++ b/src/jsx_format.hrl @@ -25,8 +25,7 @@ -record(format_opts, { space = 0, indent = 0, - output_encoding = utf8, - strict = false + output_encoding = utf8 }). diff --git a/src/jsx_verify.erl b/src/jsx_verify.erl index 957ed54..6dbd0bd 100644 --- a/src/jsx_verify.erl +++ b/src/jsx_verify.erl @@ -38,11 +38,7 @@ is_json(JSON, OptsList) when is_binary(JSON) -> P = jsx:decoder(extract_parser_opts(OptsList)), is_json(fun() -> P(JSON) end, OptsList); -is_json(F, OptsList) when is_function(F) -> - case proplists:get_value(strict, OptsList, false) of - true -> collect_strict(F(), [[]]) - ; false -> collect(F(), [[]]) - end. +is_json(F, _OptsList) when is_function(F) -> collect(F(), [[]]). extract_parser_opts(Opts) -> @@ -61,14 +57,6 @@ extract_parser_opts([K|Rest], Acc) -> end. -%% enforce only arrays and objects at top level -collect_strict({event, start_object, Next}, Keys) -> - collect(Next(), Keys); -collect_strict({event, start_array, Next}, Keys) -> - collect(Next(), Keys); -collect_strict(_, _) -> - false. - collect({event, end_json, _Next}, _Keys) -> true; @@ -166,18 +154,18 @@ false_test_() -> } ]. -less_strict_test_() -> +naked_value_test_() -> [ {"naked true", - ?_assert(is_json(<<"true">>, [{strict, false}]) =:= true) + ?_assert(is_json(<<"true">>, []) =:= true) }, {"naked number", - ?_assert(is_json(<<"1">>, [{strict, false}]) =:= true) + ?_assert(is_json(<<"1">>, []) =:= true) }, {"naked string", ?_assert(is_json( <<"\"i am not json\"">>, - [{strict, false}] + [] ) =:= true ) }