🏠 back to Observable

JSON Lines data import

Hi,
what’s the way to import a JSON Lines file?

I think that there is a direct way, but I do not find it.

Thank you

If you don’t need fancy (streaming etc) and the JSON elements don’t contain line breaks, you can use the following function

parse = t => t.split("\n")
    .filter(s => s !== "")
    .map(s => JSON.parse(s))
1 Like

Thank you @Fil I have created this hello world notebook: JSON lines import / Andrea Borruso / Observable

I am looking for something like d3.json, in which I set an URL and I have a standard data array ready to work it inside observable.

I’ve added my function Comparing JSON lines import to JSON lines import / Observable

@Fil you are very kind. Thank you