timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

to-json/pretty: "\uD83C\uDDE9\uD83C\uDDEA" is not pretty #56

Open dolmen opened 5 years ago

dolmen commented 5 years ago

Pretty output is for humans. "\uD83C\uDDE9\uD83C\uDDEA" is not pretty.

What happens:

$ perl6 -MJSON::Fast -e 'say to-json "🇩🇪", :pretty'
"\uD83C\uDDE9\uD83C\uDDEA"

Expected output:

"🇩🇪"
timo commented 5 years ago

i disagree. :pretty json output should still be valid json, as terrible as that is.

timo commented 5 years ago

welp, re-reading the multitude of json rfcs i don't understand where i got the impression that anything outside of the basic multilingual plane has to be turned into utf16 surrogate pairs that are then escaped.