google / google/json_serializable.dart
JsonKey annotation in superclass is not being used for overriden getters
- Dominant language
- Dart
- Stars
- 1.6k
- Forks
- 461
- Avg merge
- 45m
- Merged PRs (30d)
- 1
Description
Consider a structure like the following:
```dart
abstract class MyBaseClass {
@JsonKey(name: 'myCustomGetterName');
String get myGetter;
@JsonKey(name: 'myCustomFieldName');
final String myField;
}
@JsonSerializable(createFactory: false)
class MySuperclass implements MyBaseClass {
@override
String get myGetter => 'myGetterValue';
@override
final String myField = 'myFieldValue';
Map toJson() => _$MySuperclassToJson(this);
}
```
I'd expect to see a JSON result like this:
```json
{
"myCustomGetterName": "myGetterValue",
"myCustomFieldName": "myFieldValue"
}
```
Instead, the getter name isn't inherited, and I get this:
```json
{
"myGetter": "myGetterValue",
"myCustomFieldName": "myFieldValue"
}
```
Contributor guide
Assessment
This issue has not been assessed yet.