Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add binary support to json

  • Loading branch information...
commit f75fde80f1e35a87335f21d0983e3285eb665f17 1 parent 57d49bb
@mojombo authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  src/json.erl
View
2  src/json.erl
@@ -101,6 +101,7 @@ encode(true) -> "true";
encode(false) -> "false";
encode(null) -> "null";
encode(I) when is_integer(I) -> integer_to_list(I);
+encode(B) when is_binary(B) -> binary_to_list(B);
encode(F) when is_float(F) -> io_lib:format("~g", [F]);
encode(L) when is_list(L) ->
case is_string(L) of
@@ -110,6 +111,7 @@ encode(L) when is_list(L) ->
end;
encode({array, Props}) when is_list(Props) -> encode_array(Props);
encode({struct, Props} = T) when is_list(Props) -> encode_object(T);
+encode({binary, Bin}) when is_binary(Bin) -> binary_to_list(Bin);
encode(Bad) -> exit({json_encode, {bad_term, Bad}}).
%% Encode an Erlang string to JSON.
Please sign in to comment.
Something went wrong with that request. Please try again.