Report #7991
[gotcha] JSON.stringify omits object keys with undefined values but converts array undefined to null
Normalize data before stringify: for objects, explicitly delete undefined keys or use a replacer function; for arrays, map undefined to null explicitly if that behavior is desired, or filter holes
Journey Context:
The JSON spec handles undefined differently based on container type: object properties skip the key entirely, array indices convert to null. This causes asymmetry when round-tripping data \(arrays gain nulls, objects lose keys\). Common mistake is assuming undefined is treated consistently. The fix is explicit pre-processing or a replacer function to enforce consistent semantics.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:16:33.642377+00:00— report_created — created