options are now proplist style, so [comments] implies [{comments, true}] et cetera

This commit is contained in:
alisdair sullivan 2011-03-07 14:02:51 -08:00
parent 88da19783a
commit a6e7490a2b
5 changed files with 51 additions and 13 deletions

View file

@ -51,9 +51,19 @@ is_json(JSON, Opts) ->
extract_parser_opts(Opts) ->
[ {K, V} || {K, V} <-
Opts, lists:member(K, [comments, encoding, unquoted_keys])
].
extract_parser_opts(Opts, []).
extract_parser_opts([], Acc) -> Acc;
extract_parser_opts([{K,V}|Rest], Acc) ->
case lists:member(K, [comments, encoding, unquoted_keys]) of
true -> [{K,V}] ++ Acc
; false -> extract_parser_opts(Rest, Acc)
end;
extract_parser_opts([K|Rest], Acc) ->
case lists:member(K, [comments, encoding, unquoted_keys]) of
true -> [K] ++ Acc
; false -> extract_parser_opts(Rest, Acc)
end.
%% enforce only arrays and objects at top level