It is not actually in your string anywhere. The backslash is used to escape double quotes (") in the code. Try this for yourself:
IO.puts("\"")
It prints a double quote ("). The backslash tells the compiler: what follows is the special character ".
This is invalid code. The valid code is:
String.replace(string, "\\", "")
But that is not needed in your case. Try this:
"{\"year\":\"2020\",\"p\":\"1002\"}" == ~s({"year":"2020","p":"1002"})
The backslashes you might see in the console are just instructions that what follows is an otherwise special character. If this confuses you then you should read up on special characters and escaping.
This image applies to Python and not Elixir but it has a lot in common with it. Hopefully it unlocks your understanding.






















