removed now meaningless strict option from format and verify modules and associated types and specs
This commit is contained in:
parent
9eec2459f4
commit
922e3e525e
3 changed files with 8 additions and 23 deletions
|
@ -123,13 +123,11 @@
|
||||||
|
|
||||||
|
|
||||||
-type verify_opts() :: [verify_opt()].
|
-type verify_opts() :: [verify_opt()].
|
||||||
-type verify_opt() :: {strict, true | false}
|
-type verify_opt() :: {encoding, auto | supported_utf()}.
|
||||||
| {encoding, auto | supported_utf()}.
|
|
||||||
|
|
||||||
|
|
||||||
-type format_opts() :: [format_opt()].
|
-type format_opts() :: [format_opt()].
|
||||||
-type format_opt() :: {strict, true | false}
|
-type format_opt() :: {encoding, auto | supported_utf()}
|
||||||
| {encoding, auto | supported_utf()}
|
|
||||||
| {space, integer()}
|
| {space, integer()}
|
||||||
| space
|
| space
|
||||||
| {indent, integer()}
|
| {indent, integer()}
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
-record(format_opts, {
|
-record(format_opts, {
|
||||||
space = 0,
|
space = 0,
|
||||||
indent = 0,
|
indent = 0,
|
||||||
output_encoding = utf8,
|
output_encoding = utf8
|
||||||
strict = false
|
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,7 @@
|
||||||
is_json(JSON, OptsList) when is_binary(JSON) ->
|
is_json(JSON, OptsList) when is_binary(JSON) ->
|
||||||
P = jsx:decoder(extract_parser_opts(OptsList)),
|
P = jsx:decoder(extract_parser_opts(OptsList)),
|
||||||
is_json(fun() -> P(JSON) end, OptsList);
|
is_json(fun() -> P(JSON) end, OptsList);
|
||||||
is_json(F, OptsList) when is_function(F) ->
|
is_json(F, _OptsList) when is_function(F) -> collect(F(), [[]]).
|
||||||
case proplists:get_value(strict, OptsList, false) of
|
|
||||||
true -> collect_strict(F(), [[]])
|
|
||||||
; false -> collect(F(), [[]])
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
extract_parser_opts(Opts) ->
|
extract_parser_opts(Opts) ->
|
||||||
|
@ -61,14 +57,6 @@ extract_parser_opts([K|Rest], Acc) ->
|
||||||
end.
|
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) ->
|
collect({event, end_json, _Next}, _Keys) ->
|
||||||
true;
|
true;
|
||||||
|
@ -166,18 +154,18 @@ false_test_() ->
|
||||||
}
|
}
|
||||||
].
|
].
|
||||||
|
|
||||||
less_strict_test_() ->
|
naked_value_test_() ->
|
||||||
[
|
[
|
||||||
{"naked true",
|
{"naked true",
|
||||||
?_assert(is_json(<<"true">>, [{strict, false}]) =:= true)
|
?_assert(is_json(<<"true">>, []) =:= true)
|
||||||
},
|
},
|
||||||
{"naked number",
|
{"naked number",
|
||||||
?_assert(is_json(<<"1">>, [{strict, false}]) =:= true)
|
?_assert(is_json(<<"1">>, []) =:= true)
|
||||||
},
|
},
|
||||||
{"naked string",
|
{"naked string",
|
||||||
?_assert(is_json(
|
?_assert(is_json(
|
||||||
<<"\"i am not json\"">>,
|
<<"\"i am not json\"">>,
|
||||||
[{strict, false}]
|
[]
|
||||||
) =:= true
|
) =:= true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue