ndjson / ndjson-spec

Specification
680 stars 29 forks source link

Is supporting pretty printed (multi line) JSON worthwhile? #1

Closed chrisdew closed 2 years ago

chrisdew commented 11 years ago

pros:

cons:

hoegertn commented 11 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.

hoegertn commented 11 years ago

If we don't support PrettyPrint JSON we can use \n as line delimiter instead of \r\n

What is your opinion?

\cc @chrisdew

chrisdew commented 10 years ago

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.

hoegertn commented 10 years ago

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.

dominictarr commented 10 years ago

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.