Skip to content

Commit

Permalink
Fix lists encoding
Browse files Browse the repository at this point in the history
Encode a lists of dates causes a badarg exception, because the code matches the date as a proplist
  • Loading branch information
williamthome committed Oct 3, 2023
1 parent 97edfc3 commit 568cbd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jsxrecord.erl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ expand_records({K, V}) ->
expand_records(L) when is_list(L) ->
lists:map(
fun
({K, V}) -> {K, expand_records(V)};
({K, V}) when is_binary(K) -> {K, expand_records(V)};
(V) -> expand_records(V)
end,
L);
Expand Down
6 changes: 6 additions & 0 deletions test/jsxrecord_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ record_defaults(_Config) ->
dates(_Config) ->
<<"\"2008-12-10T13:30:00Z\"">> = jsxrecord:encode({{2008, 12, 10}, {13, 30, 0}}),
{{2008, 12, 10}, {13, 30, 0}} = jsxrecord:decode(<<"\"2008-12-10T13:30:00Z\"">>),

<<"[\"2008-12-10T13:30:00Z\",\"2008-12-10T13:30:00Z\"]">> =
jsxrecord:encode([{{2008, 12, 10}, {13, 30, 0}}, {{2008, 12, 10}, {13, 30, 0}}]),
[{{2008, 12, 10}, {13, 30, 0}}, {{2008, 12, 10}, {13, 30, 0}}] =
jsxrecord:decode(<<"[\"2008-12-10T13:30:00Z\",\"2008-12-10T13:30:00Z\"]">>),

ok.

times(_Config) ->
Expand Down

0 comments on commit 568cbd6

Please sign in to comment.