|
|
|
|
|
by masklinn
1652 days ago
|
|
> How do you implement a PUT endpoint where a missing JSON value is treated different than a null JSON value? Tbf that’s a pain in the ass everywhere unless you’re reifying it as a map (so manipulating a json dom). Iirc in rust the “complete” way to do this for a struct (as opposed to a map) with serde require two options and a bespoke deserializer. |
|
The Go answer is a struct that contains an IsDefined boolean (i.e. your first option), and a pointer-to-value (i.e. your second option.)
This is fine if you need it, but having to write this same logic over and over again for every type gets old... especially if your validators are tied to your types (i.e. a type per field.)