top | item 27282645

(no title)

iddqd | 4 years ago

Line separated JSON has its uses, for example when streaming data.

discuss

order

amelius|4 years ago

Ok, but what if you want to transmit two streams? You'd get something like Interlaced-newline-delimited-JSON. And so the list of required file formats knows no end.

SahAssar|4 years ago

If you're transmitting two streams you use two streams to transmit. I don't see the problem?

BugsJustFindMe|4 years ago

The only reason people care about newlines for a stream is because they've arbitrarily chosen to fetch bytes from the stream until the next newline sequence (readline instead of read). But you could just as easily look for a different sequence, like the ASCII record separator character which was invented exactly for this task, and then you wouldn't have to destructively strip newlines from your input.

nerdponx|4 years ago

I'll switch from \n to \x1E when cat, head, text editors, etc. start supporting the latter as a synonym for the former.

morelisp|4 years ago

We tell our customers our streaming API uses jsonlines for documentation purposes, but we actually just decode in a loop until EOF, and 400 at the first decode error. No separators necessary at all.