diff --git a/lib/jason.ex b/lib/jason.ex index 43bda03..b6a685c 100644 --- a/lib/jason.ex +++ b/lib/jason.ex @@ -207,7 +207,7 @@ defmodule Jason do end end - defp do_encode(input, %{pretty: pretty} = opts) do + defp do_encode(input, %{pretty: pretty} = opts) when pretty !== false do case Encode.encode(input, opts) do {:ok, encoded} -> {:ok, Formatter.pretty_print_to_iodata(encoded, pretty)} other -> other diff --git a/test/encode_test.exs b/test/encode_test.exs index 0533729..805085e 100644 --- a/test/encode_test.exs +++ b/test/encode_test.exs @@ -155,6 +155,10 @@ defmodule Jason.EncoderTest do assert to_json(%{a: 3.14159, b: 1}, pretty: true) == ~s|{\n "a": 3.14159,\n "b": 1\n}| end + test "pretty: false" do + assert to_json(%{a: 3.14159, b: 1}, pretty: false) == ~s|{"a":3.14159,"b":1}| + end + defp to_json(value, opts \\ []) do Jason.encode!(value, opts) end