Merge pull request #115 from dumbbell/honor-return_maps-option

jsx_to_term:parse_config/2: Honor `return_maps` option value
This commit is contained in:
alisdair sullivan 2017-10-22 13:52:18 -07:00 committed by GitHub
commit 6a01f3a43b

View file

@ -88,7 +88,7 @@ parse_config([labels|Rest], Config) ->
parse_config(Rest, Config#config{labels = binary});
parse_config([{return_maps, Val}|Rest], Config)
when Val == true; Val == false ->
parse_config(Rest, Config#config{return_maps = true});
parse_config(Rest, Config#config{return_maps = Val});
parse_config([return_maps|Rest], Config) ->
parse_config(Rest, Config#config{return_maps = true});
parse_config([{K, _}|Rest] = Options, Config) ->
@ -424,6 +424,10 @@ return_maps_test_() ->
[{}],
jsx:decode(<<"{}">>, [])
)},
{"an empty map", ?_assertEqual(
[{}],
jsx:decode(<<"{}">>, [{return_maps, false}])
)},
{"a small map", ?_assertEqual(
#{<<"awesome">> => true, <<"library">> => <<"jsx">>},
jsx:decode(<<"{\"library\": \"jsx\", \"awesome\": true}">>, [return_maps])