const fs=require('fs'); const path='methods/system.json'; let s=fs.readFileSync(path,'utf8'); function isEscaped(str, idx){let cnt=0; let j=idx-1; while(j>=0 && str[j]=='\\'){cnt++; j--; } return cnt%2===1;} // find headers key let ph = s.indexOf('"headers"'); if(ph===-1){console.error('no headers key'); process.exit(1)} let posOpen = s.indexOf('[', ph); if(posOpen===-1){console.error('no [ after headers'); process.exit(1)} // find matching closing bracket for headers let depth=0; let inStr=false; let posClose=-1; for(let i=posOpen;i