JuliaIO / JSON.jl

JSON parsing and printing
Other
312 stars 101 forks source link

Escape unicode character: u2028 #309

Open twavv opened 4 years ago

twavv commented 4 years ago

https://stackoverflow.com/questions/2965293/javascript-parse-error-on-u2028-unicode-character

This is mostly a non issue and only has to do with JS/JSON interop. tl;dr: not all JSON is valid JavaScript. It'd be nice if we replaced the unicode line ending character with the equivalent \u2028 to make the output parseable as JavaScript.

mortenpi commented 4 years ago

Also \u2029: http://timelessrepo.com/json-isnt-a-javascript-subset

Technically, in ECMAScript 2019 (10th edition), it is no longer necessary, since the standard now allows U+2028 and U+2029 in strings. But it's probably better to err on the safe side (probably a lot of non-2019-compatible interpreters still out there) and just escape them. In Documenter we ran into this as well and we apply additional escapes on top of what JSON.json produces.