// Name: Lines to JSON Array // Description: Converts line-separated text into a JSON array of strings. // Author: dallascrilley // GitHub: dallascrilley import "@johnlindquist/kit" const input: string = await editor({ value: "", hint: "Paste or type one item per line. Empty lines are ignored. Press Enter to convert.", }) const items: string[] = input .split(/\r?\n/) .map(s => s.trim()) .filter(s => s.length > 0) const json: string = JSON.stringify(items, null, 2) await copy(json) await notify(`Converted ${items.length} item${items.length === 1 ? "" : "s"} and copied JSON to clipboard.`) await div( md(` ### JSON Array (copied to clipboard) \`\`\`json ${json} \`\`\` `) )