Skip to content

Implement JsonKey - readonly, writeonly #569

Closed
@bsutton

Description

@bsutton

We have a class that contains fields that we need to fetch from the server but we can't send back to the server. As such we want to be able to define a field as being readonly and for symmetries sake we should have the ability to mark a field as write only.

Read only

class Team
{
@JsonKey(readOnly: true)
 List<User> members;
}

The readonly argument would cause the json serializer to suppress the generation of the members field in the toJson function.

Write only

class Team
{
@JsonKey(writeOnly: true)
 List<User> members;
}

The writeOnly argument would cause the json serializer to suppress the generation of the members field in the fromJson function.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions