bwscheddebrock_trassenplaner/search_netz.js

42 lines
1.3 KiB
JavaScript

const fs = require('fs');
function searchNetz() {
try {
const content = fs.readFileSync('Geodaten/project.json', 'utf8');
const json = JSON.parse(content);
console.log("Searching for 'netz' in project.json...");
const results = [];
function traverse(obj, path = '') {
if (typeof obj === 'string') {
if (obj.toLowerCase().includes('netz')) {
results.push({ path, value: obj });
}
} else if (Array.isArray(obj)) {
obj.forEach((item, index) => traverse(item, `${path}[${index}]`));
} else if (typeof obj === 'object' && obj !== null) {
for (const key in obj) {
traverse(obj[key], `${path}.${key}`);
}
}
}
traverse(json);
if (results.length > 0) {
console.log(`Found ${results.length} matches:`);
results.slice(0, 20).forEach(r => console.log(`${r.path}: ${r.value}`));
if (results.length > 20) console.log("...");
} else {
console.log("No matches found.");
}
} catch (e) {
console.error("Error searching project.json:", e);
}
}
searchNetz();