Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: