# obj["baz"] = arr
# var res = obj.to_pretty_json
# var exp = """{
- # "foo": 1,
- # "bar": true,
- # "baz": [2, false, "baz"]
+ # \t"foo": 1,
+ # \t"bar": true,
+ # \t"baz": [2, false, "baz"]
# }\n"""
# assert res == exp
# ~~~
buffer.append "\\\""
else if char == '\/' then
buffer.append "\\/"
- else if char < 16.ascii then
+ else if char < 16.code_point then
if char == '\n' then
buffer.append "\\n"
else if char == '\r' then
buffer.append "\\r"
else if char == '\t' then
buffer.append "\\t"
- else if char == 0x0C.ascii then
+ else if char == 0x0C.code_point then
buffer.append "\\f"
- else if char == 0x08.ascii then
+ else if char == 0x08.code_point then
buffer.append "\\b"
else
- buffer.append "\\u000{char.ascii.to_hex}"
+ buffer.append "\\u000{char.code_point.to_hex}"
end
else if char < ' ' then
- buffer.append "\\u00{char.ascii.to_hex}"
+ buffer.append "\\u00{char.code_point.to_hex}"
else
buffer.add char
end
i += 1
char = text[i]
if char == 'b' then
- char = 0x08.ascii
+ char = 0x08.code_point
else if char == 'f' then
- char = 0x0C.ascii
+ char = 0x0C.code_point
else if char == 'n' then
char = '\n'
else if char == 'r' then
if code >= 128 then
char = '?'
else
- char = code.ascii
+ char = code.code_point
end
i += 4
end