3 ms·
There are all kinds of solutions ("why not just use undefined instead?"), but whichever it is, a decision has to be made, documented, remembered, and edge cases
by rendall 4y ago
There are all kinds of solutions ("why not just use undefined instead?"), but whichever it is, a decision has to be made, documented, remembered, and edge cases decided. Whatever you have, now the API has a non-obvious custom spec just for that API alone. It's not a "why not just".
I guarantee, another dev would come along, look at the custom spec, and think "Why not just use JSON Patch?"
- crabmusket 4y agoI would expect in such cases that JSON Merge Patch, and its media type, would be used to head off bikeshedding discussions. https://www.rfc-editor.org/rfc/rfc7396.html https://www.rfc-editor.org/rfc/rfc7396.html
- ratww 4y agoundefined would in theory be slightly "better" for deleting values (the value { key: undefined } serializes to {}), but, alas, it isn't supported by JSON, so you'd have to use a custom serializer and deserializer for it to even work.