Task #27243
Implement Optional type to handle optional fields in web service requests
0%
Description
We need a way to distinguish between fields that were explicitly provided in JSON requests and fields that were omitted entirely. We used to use pointers to identify this but using generics we can design a simple solution. Optional[T]
type with a custom unmarshaler can correctly detects when a field is provided vs not provided in JSON and provide simple way to identify and get the value correctly compared to handling pointers.
Updated by Sachin Divekar about 1 month ago
Added a generic Optional type to the wscutils package that helps distinguish between fields that were explicitly provided in a JSON request (even with zero values) and fields that were not provided at all. It tracks field presence, handles null values, and provides a convenient Get() method for safely accessing values.
- Written tests
- Written examples and tutorial