Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chrisdew opened this issue Jul 8, 2013 · 5 comments
Closed

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

chrisdew opened this issue Jul 8, 2013 · 5 comments

Comments

@chrisdew
Copy link
Member

chrisdew commented Jul 8, 2013

pros:

  • more flexible input is often a good thing
  • allows use of JSON libraries which only support pretty printing
  • more readable display of output when connecting via netcat/telnet

cons:

  • bad input breaks decoding - the current decoder cannot tell the difference between an incomplete JSON message and bad input - my clever hack to continue using 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).
@hoegertn
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

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.

@chrisdew chrisdew reopened this Feb 21, 2014
@hoegertn
Copy link
Member

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
Copy link

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.

@finnp finnp reopened this Oct 19, 2014
finnp pushed a commit that referenced this issue Oct 20, 2022
* update rfc links

* update obsoleted RFCs (#1)

Co-authored-by: Jesse Jackson <jsejcksn@users.noreply.github.com>
@finnp finnp closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants