It's Plug supposed to parse JSON with removing return carriages or newlines?

I have this code

type or paste defmodule MyApp.PlugServer.Plugs.CheckRequestFields do
    

    def init(options), do: options
        
    def call(%Plug.Conn{request_path: path} = conn, opts) do
        {:ok, body, conn} = Plug.Conn.read_body(conn, opts)
        
        IO.inspect(body)

        if path in opts[:paths], do: verify_request_fields!(conn.params, opts[:fields])
        conn
    end

    defp verify_request_fields!(params, fields) do
        miss = []
        fields
        |> Enum.reduce(miss, fn x ->
          if Map.get(params, x) == nil do
            miss ++ [x]
          else
            miss
          end
        end)
        IO.inspect(fields)
      end


end
here

When I try to log the body, I got "{\n\t\"user\": \"Pedri\"\n}"althought i’m sending
{
“user”: “Pedri”
}
as body
the endpoint

defmodule TestesPay.MyRouter do
  use Plug.Router
  alias MyApp.PlugServer.Plugs.CheckRequestFields
  
plug Plug.Parsers,
    parsers: [:urlencoded, :json],
    json_decoder: Jason

  plug CheckRequestFields, fields: ["user", "age"], paths: ["/hello"]
  plug :match
  plug :dispatch

  get "/hello" do
    send_resp(conn, 200, "world")
  end

  match _ do
    send_resp(conn, 404, "oops")
  end
end

I must remove special characters by myself or i’m missing some configuration?

These are not special characters, it’s the same thing that you sent.

How are you getting the "{\n\t\"user\": \"Pedri\"\n}" string exactly? In your log?

i’m using IO.inspect, it’s not running i’m just checking if its working. Should I be doing different?

also, this is the output if I load the plug.parser or not so it looks like its not working

Try putting your plug below the plug :match line?

no changes, same output

updated to this:

plug Plug.Parsers,
  parsers: [:urlencoded, :json],
  pass: ["*/*"],
  json_decoder: Jason

and verified that Jason its installed as a dep

Are you sending the content type header ?

yes, I think the problem is I was using IO.inspect(), that print special characters, I used IO.puts and the string was printed just fine