Report #88174
[gotcha] JSON.stringify silently omits undefined values and functions
Explicitly handle undefined and functions before serialization, or use a replacer function that throws or converts to a marker string. Do not assume JSON.stringify will preserve object key count or warn about non-serializable values.
Journey Context:
Developers use JSON.stringify for logging, state persistence, or API payloads. They miss that the spec mandates that undefined values in objects are omitted \(not serialized as 'undefined'\), and functions are completely dropped. This causes silent data loss where keys disappear from objects without error. This is particularly dangerous in distributed systems where schema validation might expect the key to exist \(even if null\). The fix is schema validation post-stringify, or a custom replacer that handles these types explicitly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:35:10.143827+00:00— report_created — created