always return maps if the macro maps_always is defined

This commit is contained in:
alisdair sullivan 2014-12-18 15:58:19 -08:00
parent 8592742ded
commit d4d838d4f4
2 changed files with 8 additions and 1 deletions

View file

@ -1,4 +1,6 @@
{erl_opts, [ {erl_opts, [
% uncomment to always decode to maps
% {d, maps_always},
{platform_define, "R14|R15", 'no_binary_to_whatever'}, {platform_define, "R14|R15", 'no_binary_to_whatever'},
{platform_define, "^((?!R1[456]).)*$", 'maps_support'} {platform_define, "^((?!R1[456]).)*$", 'maps_support'}
]}. ]}.

View file

@ -69,9 +69,14 @@
-spec to_term(Source::binary(), Config::config()) -> json_value(). -spec to_term(Source::binary(), Config::config()) -> json_value().
-ifdef(maps_always).
to_term(Source, Config) when is_list(Config) ->
(jsx:decoder(?MODULE, [return_maps] ++ Config, jsx_config:extract_config(Config)))(Source).
-endif.
-ifndef(maps_always).
to_term(Source, Config) when is_list(Config) -> to_term(Source, Config) when is_list(Config) ->
(jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source). (jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source).
-endif.
parse_config(Config) -> parse_config(Config, #config{}). parse_config(Config) -> parse_config(Config, #config{}).