Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
std/json fails to escape most non-printables, breaking generation and parsing #10541
import json var ary = newJArray() for i in 0..255: ary.add(%($i & "=" & $i.chr)) let first = ary.pretty let second = first.parseJson.pretty echo first echo second doAssert(first == second)
This proc (and the accompanying parser) should probably be rewritten according to spec.
Discovered here: niv/neverwinter.nim#4
Tested on 19.2 and latest #head.
Yes, here is the PR: #10437 — that solves one point of this issue ("The generated unicode escape sequences "\uXXXX" are generated from ordinal values, but the spec requires them to be hexadecimal")
The remaining points are:
I tried to also fix the other problem (positions 128 .. 255) based on your example, but my fix only caused other problems so I reverted it.