How to Read JSONL files
To read a JSONL file, we use IO.FS.lines to get an array of strings and then parse each non-empty line.
def readJsonlFile (path : System.FilePath) :
IO (Array Json) := do
let lines ← IO.FS.lines path
let mut result := #[]
for line in lines do
let line := line.trim
if line.isEmpty then continue
match Json.parse line with
| .ok j => result := result.push j
| .error err =>
throw <| IO.userError s!"Failed to parse line: {err}"
return result