Skip to content

How to exclude field from toJson serialization? #1100

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
AlexanderBykin opened this issue Feb 17, 2022 · 4 comments · Fixed by #1256
Closed

How to exclude field from toJson serialization? #1100

AlexanderBykin opened this issue Feb 17, 2022 · 4 comments · Fixed by #1256

Comments

@AlexanderBykin
Copy link

Hi

Currently JsonKey annotation have ignore parameter, but it's generalized for both fromJson and toJson.
The idea is to have a control over which fields can be serialized via toJson method and then sent over internet.

Could there be implemented additional parameter bool? excludeToJson ?

@JulianSwales
Copy link

I'd actually like the above and one step further.. I have a backend SQL database that on Inserts has some Not Null with default database fields. So whilst I'm using this solution, toJson converts to a null value as it should when it's a nullable field, but if it's null on the data side I'd like to exclude the field in the toJson..
So I need the option above for things like the id field that's automatically generated on insert, but also an option to dynamically exclude fields based on their value.

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 17, 2022

Duplicate of #569

Trying to align all of these requests into one place!

@kevmoo kevmoo closed this as completed Nov 17, 2022
@kevmoo
Copy link
Collaborator

kevmoo commented Nov 22, 2022

I have a (draft) PR out on this. I'd LOVE (early) feedback about if this works for what folks need here: #1256

I still need to do some documentation and testing...

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 22, 2022

@JulianSwales – please open a separate issue for your request!

kevmoo added a commit that referenced this issue Nov 22, 2022
Deprecate JsonKey.ignore

Fixes #24
Fixes #274
Fixes #537
Fixes #569
Fixes #797
Fixes #1100
Fixes #1244
kevmoo added a commit that referenced this issue Nov 22, 2022
Deprecate JsonKey.ignore

Fixes #24
Fixes #274
Fixes #537
Fixes #569
Fixes #797
Fixes #1100
Fixes #1244
kevmoo added a commit that referenced this issue Nov 30, 2022
… serialization (#1256)

Deprecate `JsonKey.ignore`

Fixes #24
Fixes #274
Fixes #537
Fixes #569
Fixes #797
Fixes #1100
Fixes #1244
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants