4 ms·
well actually they are the same if you say (pseudocode) ``` const jsonLParser = (streamOfLines) => { for (line in streamOfLines) { if line.trim() ===
by oulipo 3y ago
well actually they are the same if you say (pseudocode)
```
const jsonLParser = (streamOfLines) => {
for (line in streamOfLines) {
if line.trim() === "[" || line.trim() === "]" -> skip
if line.endswith(',') -> line = line.trimEnd(',')
yield JSON.parse(line)
}
}
```
this allows your API to be consumed both by JSON parsers and JSONL parsers