Closed chrisdew closed 2 years ago
Sorry for my late answer. I think we could drop PrettyPrint support because the parser doesn't need to be JSON aware in this case.
If we don't support PrettyPrint JSON we can use \n as line delimiter instead of \r\n
What is your opinion?
\cc @chrisdew
Yes, I'd be happy to drop pretty print support.
I've always thought that we should output \n (0x0a) as the separator, but be tolerant of '\r\n' on input.
I don't understand how the choice of separator is linked with pretty print support.
The problem with pretty print support is, that we need a stream parser to find JSON objects. If we use one line JSON only we can split at newlines without parsing the JSON.
It's recently occured to me that you can have pretty printing in line delimited json if you use \n\n
as the delimiter. Usually, json libraries produce output without consecutive newlines (that I have used, at least) and of course, json without extra whitespace will still work too.
The only (slight) difficulty is \r\n\r\n
, but that only makes the splitter silghtly more complicated.
pros:
cons:
JSON.parse
isn't so clever in practise (I do have a work around, but the implementation is not trivial and trivial implementation is a major point using Line Delimited JSON).