Skip to content

Commit 1dfd2eb

Browse files
authored
Remove unecessary escape for quotes (michalmuskala#135)
1 parent f989315 commit 1dfd2eb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/encode.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ defmodule Jason.Encode do
216216
# TODO: benchmark the effect of inlining the to_iso8601 functions
217217
for module <- [Date, Time, NaiveDateTime, DateTime] do
218218
defp struct(value, _escape, _encode_map, unquote(module)) do
219-
[?\", unquote(module).to_iso8601(value), ?\"]
219+
[?", unquote(module).to_iso8601(value), ?"]
220220
end
221221
end
222222

223223
defp struct(value, _escape, _encode_map, Decimal) do
224224
# silence the xref warning
225225
decimal = Decimal
226-
[?\", decimal.to_string(value, :normal), ?\"]
226+
[?", decimal.to_string(value, :normal), ?"]
227227
end
228228

229229
defp struct(value, escape, encode_map, Fragment) do
@@ -255,7 +255,7 @@ defmodule Jason.Encode do
255255
end
256256

257257
defp encode_string(string, escape) do
258-
[?\", escape.(string, string, 0), ?\"]
258+
[?", escape.(string, string, 0), ?"]
259259
end
260260

261261
slash_escapes = Enum.zip('\b\t\n\f\r\"\\', 'btnfr"\\')

lib/encoder.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ end
217217

218218
defimpl Jason.Encoder, for: [Date, Time, NaiveDateTime, DateTime] do
219219
def encode(value, _opts) do
220-
[?\", @for.to_iso8601(value), ?\"]
220+
[?", @for.to_iso8601(value), ?"]
221221
end
222222
end
223223

224224
defimpl Jason.Encoder, for: Decimal do
225225
def encode(value, _opts) do
226226
# silence the xref warning
227227
decimal = Decimal
228-
[?\", decimal.to_string(value), ?\"]
228+
[?", decimal.to_string(value), ?"]
229229
end
230230
end
231231

0 commit comments

Comments
 (0)