diff --git a/src/jsx.erl b/src/jsx.erl index f5615f3..a08f696 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -243,10 +243,10 @@ load_tests([Test|Rest], Dir, Acc) -> end. -%% if the json, erlang or jsx values are lists, assume they're a path to a file that should +%% if the json, eep0018 or jsx values are lists, assume they're a path to a file that should %% be read with file:read_file/1 parse_test([{Key, Path}|Rest], Test) when is_list(Path) -> - case lists:member(Key, [json, erlang, jsx]) of + case lists:member(Key, [json, eep0018, jsx]) of true -> case file:read_file(Path) of {ok, Bin} -> parse_test(Rest, [{Key, Bin}] ++ Test) diff --git a/src/jsx_encoder.erl b/src/jsx_encoder.erl index 65a6fac..66df93e 100644 --- a/src/jsx_encoder.erl +++ b/src/jsx_encoder.erl @@ -65,6 +65,7 @@ term_to_events(Term) -> proplist_to_events([{Key, Term}|Rest], Acc) -> Event = term_to_event(Term), EncodedKey = key_to_event(Key), + io:format("~p~n~p~n~n", [EncodedKey, Acc]), case key_repeats(EncodedKey, Acc) of false -> proplist_to_events(Rest, Event ++ EncodedKey ++ Acc) ; true -> erlang:error(badarg) @@ -101,9 +102,10 @@ key_to_event(Key) when is_binary(Key) -> [{key, json_escape(Key)}]. -key_repeats([Key], [Key|_]) -> true; +key_repeats([{key, Key}], [{key, Key}|_Rest]) -> true; +key_repeats(Key, [{Key, _Value}|_Rest]) -> true; key_repeats(Key, [_|Rest]) -> key_repeats(Key, Rest); -key_repeats(_, []) -> false. +key_repeats(_Key, []) -> false. %% conversion of floats to 'nice' decimal output. erlang's float implementation is almost