You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, freezed allows deserializing/serializing typed objects using generics. However, in certain cases, it may be useful to specify a different JSON key dynamically for the generic field, depending on how it’s being used.
The proposal is to extend the fromJson method by adding an extra parameter, jsonKey, which would allow specifying the JSON field that contains the generic data at the time of deserialization/serializations:
In an API context, it’s common to have recurring response or request body structures where some fields are specific while others are common. By adding the ability to specify the JSON key at deserialization time, the code becomes more flexible and capable of handling these variations without duplicating serialization/deserialization logic.
If the idea is considered valid, I can work on developing the system and submit a pull request to integrate this functionality.
The text was updated successfully, but these errors were encountered:
Currently, freezed allows deserializing/serializing typed objects using generics. However, in certain cases, it may be useful to specify a different JSON key dynamically for the generic field, depending on how it’s being used.
Example
Proposal
The proposal is to extend the fromJson method by adding an extra parameter, jsonKey, which would allow specifying the JSON field that contains the generic data at the time of deserialization/serializations:
Example
Motivation
In an API context, it’s common to have recurring response or request body structures where some fields are specific while others are common. By adding the ability to specify the JSON key at deserialization time, the code becomes more flexible and capable of handling these variations without duplicating serialization/deserialization logic.
If the idea is considered valid, I can work on developing the system and submit a pull request to integrate this functionality.
The text was updated successfully, but these errors were encountered: