json-lines icon indicating copy to clipboard operation
json-lines copied to clipboard

Document how to embed newlines

Open tacman opened this issue 2 years ago • 1 comments

The JSON I'd like to store as jsonl has linefeeds (one of the fields is a block of mardown text).

Is there special way to encode this? I'm not seeing any examples, here or on other sites.

will this work?

{"message": "hello

world"}

tacman avatar Mar 03 '23 20:03 tacman

Here are related comments found online.

https://community.snowflake.com/s/article/Escaping-new-line-character-in-JSON-to-avoid-data-loading-errors https://www.geeksforgeeks.org/how-to-handle-newlines-in-json/

And this discussion goes into some good detail...

https://github.com/wardi/jsonlines/issues/35

Basically, the newlines within JSON should already be represented as textual \n sequences, rather than the newline ASCII characters that delimit each full record. If your source JSON hasn't done this, it possibly means that it wasn't encoded to JSON correctly. If you open it up in a plain-text editor, do you see \n or a real line break?

ConnectGrid avatar Apr 11 '23 05:04 ConnectGrid