Files
chunyu_prject_react/debug_zh.cjs
T
2026-08-05 23:59:22 +08:00

49 lines
1.8 KiB
JavaScript

const fs = require('fs');
const filePath = 'c:\\Users\\12914\\Desktop\\vscode\\chunyu_prject_react\\src\\locales\\zh.json';
const content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');
console.log('Total lines:', lines.length);
// Find line with potential issues - look for unescaped quotes
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
// Check for single-line strings with unescaped quotes
if (line.match(/^\s*"[^"]*":\s*".*".*".*".*".*".*"/) && !line.endsWith(',') && !line.endsWith('"') && !line.endsWith(']') && !line.endsWith('}')) {
// suspicious
}
}
// Try to find the actual error location
const pos = 59065;
console.log('Character at pos:', content.charCodeAt(pos), content[pos]);
console.log('Context around position:');
console.log('---');
console.log(content.substring(Math.max(0, pos - 200), pos + 200));
console.log('---');
// Try incremental parse by reading line by line
// Print lines near 2279
console.log('\nLines around 2279:');
for (let i = Math.max(0, 2275); i < Math.min(lines.length, 2285); i++) {
console.log((i+1) + ': ' + lines[i]);
}
// Try to find the real error by parsing small chunks
// Actually, use the error info more carefully
console.log('\nTrying to find the actual problematic line:');
let accumulated = '';
for (let i = 0; i < lines.length; i++) {
accumulated += lines[i] + '\n';
try {
JSON.parse(accumulated);
} catch (e) {
if (e.message.includes('Unexpected end')) {
// still building
} else {
console.log(`Error at or before line ${i+1}: ${e.message}`);
console.log(lines[i]);
// Print surrounding
for (let j = Math.max(0, i-3); j < Math.min(lines.length, i+3); j++) {
console.log((j+1) + ': ' + lines[j]);
}
break;
}
}
}