google / google/json_serializable.dart

Option to exclude "synthetic" fields

Open
#1,151 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.6k
Forks
461
Avg merge
45m
Merged PRs (30d)
1

Description

I have models with various derived getters, where the underlying data is all expressed in member variables, but some more useful versions are provided by getters and in some cases associated setters. In my case, I'd like to ignore these "synthetic" fields when handling json representations. At the moment I have to either mark all those getters as being ignored, or ignore unannotated and then specifically include the member variables. It would be great to have a configuration option to handle that at the file and/or project level.

If this is something that interests you I could probably put together a PR for it, I don't think it would be that difficult (`isSynthetic` is readable on the field), though I'd have to figure out how to plum in the configuration options correctly, and the synthetic documentation is limited enough that I can't be sure I've understood it correctly. So let me know if that's a direction you'd like to see, and I can look into it further at some point.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.