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
he problem arises when I attempt to define two fields (id and username) with the same @ JsonKey(name: 'profiles') annotation. This results in the following error:
More than one field has the JSON key for name "profiles".
Questions
Is there a proper way to handle such cases where multiple values need to be extracted from a single nested object?
Would this be a feasible update for the json_serializable package to support such scenarios? If so, I would be happy to contribute and attempt a fix for this functionality.
Additional Context
While I have implemented custom converters (_IdConverter and _UsernameConverter) to handle the extraction, the limitation of having only one field with the same JSON key name makes this approach impractical. I am looking for a cleaner and more intuitive solution.
Let me know your thoughts on this issue. Any guidance or recommendations for best practices would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
Problem Description:
I am encountering an issue with parsing nested JSON fields using json_serializable in Dart. Below is the JSON structure I am receiving:
I am trying to extract both the id and username fields from the nested profiles object using the following freezed class:
he problem arises when I attempt to define two fields (id and username) with the same @ JsonKey(name: 'profiles') annotation. This results in the following error:
More than one field has the JSON key for name "profiles".
Questions
Additional Context
While I have implemented custom converters (_IdConverter and _UsernameConverter) to handle the extraction, the limitation of having only one field with the same JSON key name makes this approach impractical. I am looking for a cleaner and more intuitive solution.
Let me know your thoughts on this issue. Any guidance or recommendations for best practices would be greatly appreciated!
The text was updated successfully, but these errors were encountered: