Parse and Stringify JSON
JavaScriptSafely round-trip JSON with JSON.parse and JSON.stringify.
const raw = '{"name":"chris","tags":["js","ts"]}';
const data = JSON.parse(raw);
data.tags.push('node');
console.log(JSON.stringify(data, null, 2));
Safely round-trip JSON with JSON.parse and JSON.stringify.
const raw = '{"name":"chris","tags":["js","ts"]}';
const data = JSON.parse(raw);
data.tags.push('node');
console.log(JSON.stringify(data, null, 2));