const iter = (obj, key, lines) => { if (obj === null) { lines.push(`${key}=null;`) return } if (Array.isArray(obj)) { lines.push(`${key}=[];`) obj.forEach((v, idx) => { iter(v, `${key}[${idx}]`, lines); }); return } if (typeof obj === "object") { lines.push(`${key}={};`) for (const [k,v] of Object.entries(obj)) { iter(v, `${key}.${k}`, lines); } return } if (typeof obj === "string") { lines.push(`${key}=${JSON.stringify(obj)};`); return } lines.push(`${key}=${obj};`) } export const gronify = (obj) => { const lines = [] iter(obj, "json", lines) return lines.join('\n'); }