Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions json_serialization/writer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ template writeValueStringLike(w, value) =
of '\f': addPrefixSlash 'f' # \x0c
of '\r': addPrefixSlash 'r' # \x0d
of '"' : addPrefixSlash '\"'
of '\\': addPrefixSlash '\\'
of '\x00'..'\x07', '\x0b', '\x0e'..'\x1f':
s.write "\\u00"
s.write hexChars[(uint8(c) shr 4) and 0x0f]
Expand Down
1 change: 1 addition & 0 deletions tests/test_writer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ suite "Test writer":

test "escapes":
check Json.encode("\x12") == """"\u0012""""
check Json.encode("""a\b""") == """"a\\b""""

test "Empty object":
type NoFields = object
Expand Down