Report #53576
[gotcha] JSON.stringify silently drops undefined in objects but converts to null in arrays
Explicitly handle undefined before serialization; use a replacer function to normalize undefined to null or omit conditionally; never assume round-trip fidelity with undefined
Journey Context:
In objects, keys with undefined values are omitted entirely. In arrays, undefined becomes null to preserve array length. This asymmetry causes data integrity issues: \{a: undefined\} serializes as \{\}, but \[undefined\] serializes as \[null\]. Common mistake is expecting undefined to survive JSON round-trip or expecting consistent treatment across data structures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:25:33.275809+00:00— report_created — created