diff --git a/rebar.config b/rebar.config index b2653a2..38858b5 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,6 @@ {erl_opts, [ + % uncomment to always decode to maps + % {d, maps_always}, {platform_define, "R14|R15", 'no_binary_to_whatever'}, {platform_define, "^((?!R1[456]).)*$", 'maps_support'} ]}. \ No newline at end of file diff --git a/src/jsx_to_term.erl b/src/jsx_to_term.erl index d5db2c3..4ace068 100644 --- a/src/jsx_to_term.erl +++ b/src/jsx_to_term.erl @@ -69,9 +69,14 @@ -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) -> (jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source). - +-endif. parse_config(Config) -> parse_config(Config, #config{}).