Project

General

Profile

Task #27243

Implement Optional type to handle optional fields in web service requests

Added by Sachin Divekar about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
-
Start date:
05/05/2025
Due date:
% Done:

0%

Estimated time:

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.

Also available in: Atom PDF