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
I don't know if null values are serialized into a JSON string as
{ "someNullableField": null }
of if the map entry is simply omitted by the JSON string serializer when the value is null, but either way, it would be more optimal in terms of time and space to only add non-null fields to the map:
Map<String, dynamic> _$PersonToJson(Person instance) =><String, dynamic>{
if (instance.firstName !=null) 'firstName': instance.firstName,
if (instance.lastName !=null) 'lastName': instance.lastName,
};
Given a serializable class with nullable fields
firstName
andlastName
:currently the code generator generates the following
toJson
method given a nullable fieldsomeNullableField
:I don't know if null values are serialized into a JSON string as
of if the map entry is simply omitted by the JSON string serializer when the value is
null
, but either way, it would be more optimal in terms of time and space to only add non-null fields to the map:Related:
@JsonKey(fromJson)
#1356The text was updated successfully, but these errors were encountered: