Skip to content

Add option to omit null fields in fromJson constructor or define default values #74

Closed
@AlexanderJohr

Description

@AlexanderJohr

Great Library. Finally something to replace Dartson with. However: When deserializing fields that aren't in the json, they will be written to the object as null. In Angular I then get errors like "boolean expression must not be null". I would like to keep the default values assigned to the fields instead of having those overwritten by null:

// Please keep my assigned value, don't overwrite with null
bool myBool = true

Or maybe setting the default value with an annotation would be useful.

@JsonKey(default: true)
bool myBool

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions