How do I preserve undefined values when doing JSON.stringify(hash)?
Here\'s an example:
var hash = { \"name\" : \"boda\", \"email\" : undefined,
You can preserve the key by converting to null since a valid JSON does not allow undefined;
null
undefined
Simple one liner:
JSON.stringify(obj, (k, v) => v === undefined ? null : v)