Implemented a custom JSON parser in the parseLogLines function to handle nested JSON objects within the log lines.
This commit is contained in:
@@ -105,7 +105,16 @@ function parseLogLines(data) {
|
||||
if (line.trim() !== '') {
|
||||
try {
|
||||
const unescapedLine = line.replace(/\\"/g, '"');
|
||||
const parsedLog = JSON.parse(unescapedLine);
|
||||
const parsedLog = JSON.parse(unescapedLine, (key, value) => {
|
||||
if (typeof value === 'string') {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
validLogs.push(parsedLog);
|
||||
} catch (parseError) {
|
||||
console.error(`Error parsing log line at index ${index}: ${parseError.message}`);
|
||||
|
||||
Reference in New Issue
Block a user