-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1400 Co-authored-by: Syméon ROUGEVIN <symeon@oclocher.fr> Co-authored-by: Kevin Moore <kevmoo@google.com>
- Loading branch information
1 parent
324acee
commit 5b46ef9
Showing
18 changed files
with
142 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'json_keys_example.g.dart'; | ||
|
||
@JsonSerializable(createJsonKeys: true, fieldRename: FieldRename.kebab) | ||
class Model { | ||
Model({ | ||
required this.firstName, | ||
required this.lastName, | ||
this.ignoredName, | ||
}); | ||
|
||
factory Model.fromJson(Map<String, Object?> json) => _$ModelFromJson(json); | ||
|
||
final String firstName; | ||
|
||
@JsonKey(name: 'LAST_NAME') | ||
final String lastName; | ||
|
||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
final String? ignoredName; | ||
|
||
String get fullName => '$firstName $lastName'; | ||
|
||
Map<String, Object?> toJson() => _$ModelToJson(this); | ||
} | ||
|
||
// TODO: use this once https://github.com/dart-lang/sdk/issues/54543 is fixed | ||
typedef ModelJsonKeys = _$ModelJsonKeys; | ||
|
||
// Work-around until https://github.com/dart-lang/sdk/issues/54543 is fixed | ||
Set<String> get keys => {_$ModelJsonKeys.firstName, _$ModelJsonKeys.lastName}; |
24 changes: 24 additions & 0 deletions
24
json_serializable/test/integration/json_keys_example.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gah! need to clean this up @ChreSyr !