If an attribute is null, I would prefer to simply not serialize it.
That’s interesting. I’m on the opposite team. If a customer model defines an optional birthday, for instance, I’d rather have it serialized as a null value if it’s not available for a specific customer.
To be fair, just because
obj.foo
is undefined, that doesn’t mean the key is missing. It could also be assigned the value undefined.const obj = { foo: undefined }
vsconst obj = {}