lib/json.rb in json-0.4.0 vs lib/json.rb in json-0.4.1
- old
+ new
@@ -221,11 +221,11 @@
when '\\b' then "\b"
when '\\f' then "\f"
when '\\n' then "\n"
when '\\r' then "\r"
when '\\t' then "\t"
- when '\"' then '"'
+ when '\\"' then '"'
else
if JSON.support_unicode? and $KCODE == 'UTF8'
JSON.utf16_to_utf8($~[1])
else
# if utf8 mode is switched off or unicode not supported, try to
@@ -405,10 +405,10 @@
when char == ?\t then result << '\t'
when char == ?\n then result << '\n'
when char == ?\f then result << '\f'
when char == ?\r then result << '\r'
when char == ?" then result << '\"'
- when char == ?\\ then result << '\\'
+ when char == ?\\ then result << '\\\\'
when char.between?(0x0, 0x1f) then result << "\\u%04x" % char
when char.between?(0x20, 0x7f) then result << char
when !(JSON.support_unicode? && $KCODE == 'UTF8')
# if utf8 mode is switched off or unicode not supported, just pass
# bytes through: