google / google/json_serializable.dart
Bug report - @JsonKey(includeFromJson: false) malfunctions
Open
Investigation needed
- Dominant language
- Dart
- Stars
- 1.6k
- Forks
- 461
- Avg merge
- 45m
- Merged PRs (30d)
- 1
Description
Here's a test class
```
@JsonSerializable()
class TestClass {
TestClass({
this.a,
});
@JsonKey(includeFromJson: false)
String? a;
factory TestClass.fromJson(Map json) => _$TestClassFromJson(json);
Map toJson() => _$TestClassToJson(this);
}
```
Generated code.
```
TestClass _$TestClassFromJson(Map json) => TestClass();
Map _$TestClassToJson(TestClass instance) =>
{};
```
`TestClassToJson` should include `String a` but it doesn't. It excludes `String a` from `TestClassFromJson` and `TestClassToJson` both.
json_serializable: ^6.7.0
json_annotation: ^4.8.1
Contributor guide
Assessment
This issue has not been assessed yet.