Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add json_encode for associative list to an object #52

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mochijson.erl
Expand Up @@ -118,6 +118,8 @@ json_encode(F, _State) when is_float(F) ->
mochinum:digits(F); mochinum:digits(F);
json_encode(L, State) when is_list(L); is_binary(L); is_atom(L) -> json_encode(L, State) when is_list(L); is_binary(L); is_atom(L) ->
json_encode_string(L, State); json_encode_string(L, State);
json_encode([{_K,_V}|_PropsT]=Props, State) ->
json_encode_proplist(Props, State);
json_encode({array, Props}, State) when is_list(Props) -> json_encode({array, Props}, State) when is_list(Props) ->
json_encode_array(Props, State); json_encode_array(Props, State);
json_encode({struct, Props}, State) when is_list(Props) -> json_encode({struct, Props}, State) when is_list(Props) ->
Expand Down
2 changes: 2 additions & 0 deletions src/mochijson2.erl
Expand Up @@ -139,6 +139,8 @@ json_encode([{K, _}|_] = Props, State) when (K =/= struct andalso
json_encode_proplist(Props, State); json_encode_proplist(Props, State);
json_encode({struct, Props}, State) when is_list(Props) -> json_encode({struct, Props}, State) when is_list(Props) ->
json_encode_proplist(Props, State); json_encode_proplist(Props, State);
json_encode([{_K,_V}|_PropsT]=Props, State) ->
json_encode_proplist(Props, State);
json_encode(Array, State) when is_list(Array) -> json_encode(Array, State) when is_list(Array) ->
json_encode_array(Array, State); json_encode_array(Array, State);
json_encode({array, Array}, State) when is_list(Array) -> json_encode({array, Array}, State) when is_list(Array) ->
Expand Down