Browse Source

Merge pull request #78 from sile/fix-term-to-json-string

Don't insert newlines when encoding unknown terms using `jsone:term_to_json_string/1`
Takeru Ohta 2 years ago
parent
commit
a7f0900d82
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/jsone.erl

+ 1 - 1
src/jsone.erl

@@ -424,7 +424,7 @@ try_encode(JsonValue, Options) ->
 %% @doc Converts the given term `X' to its string representation (i.e., the result of `io_lib:format("~p", [X])').
 %% @doc Converts the given term `X' to its string representation (i.e., the result of `io_lib:format("~p", [X])').
 -spec term_to_json_string(term()) -> {ok, json_string()} | error.
 -spec term_to_json_string(term()) -> {ok, json_string()} | error.
 term_to_json_string(X) ->
 term_to_json_string(X) ->
-    {ok, list_to_binary(io_lib:format("~p", [X]))}.
+    {ok, list_to_binary(io_lib:format("~0p", [X]))}.
 
 
 
 
 %% @doc Convert an IP address into a text representation.
 %% @doc Convert an IP address into a text representation.