parseJSONL<T> function
Parse JSONL data from a string, skipping malformed lines.
Implementation
List<T> parseJSONL<T>(String data) {
final stripped = _stripBOM(data);
final results = <T>[];
var start = 0;
while (start < stripped.length) {
var end = stripped.indexOf('\n', start);
if (end == -1) end = stripped.length;
final line = stripped.substring(start, end).trim();
start = end + 1;
if (line.isEmpty) continue;
try {
results.add(json.decode(line) as T);
} catch (_) {
// Skip malformed lines
}
}
return results;
}