diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 1b3d6be2..3b95a588 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,7 +1,7 @@ -## 4.9.0-wip +## 4.9.0 - Require Dart 3.0 -- Added `JsonSerializable(createJsonKeys: true)`. +- Add `JsonSerializable(createJsonKeys: true)`. ([#1401](https://github.com/google/json_serializable.dart/pull/1401)) ## 4.8.1 diff --git a/json_annotation/lib/src/json_serializable.dart b/json_annotation/lib/src/json_serializable.dart index 91600f09..fb4d8ead 100644 --- a/json_annotation/lib/src/json_serializable.dart +++ b/json_annotation/lib/src/json_serializable.dart @@ -88,16 +88,19 @@ class JsonSerializable { final bool? createFieldMap; /// If `true` (defaults to false), a private class `_$ExampleJsonKeys` - /// constant is created in the generated part file. + /// class is created in the generated part file. /// - /// This class will contain every property, with the json key as value, - /// exposing a secured way to access the json key from the property. + /// This class will contain every property as a [String] field with the JSON + /// key as the value. /// /// ```dart /// @JsonSerializable(createJsonKeys: true) /// class Example { - /// // ... - /// static const jsonKeys = _$PublicationImplJsonKeys(); + /// @JsonKey(name: 'LAST_NAME') + /// String? firstName; + /// + /// // Will have the value `LAST_NAME` + /// static const firstName = _$ExampleJsonKeys.firstName; /// } /// ``` final bool? createJsonKeys; diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index aabbd968..5d748a0e 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -1,5 +1,5 @@ name: json_annotation -version: 4.9.0-wip +version: 4.9.0 description: >- Classes and helper functions that support JSON code generation via the `json_serializable` package. diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 9ae8f098..77bf34c1 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,9 +1,8 @@ ## 6.8.0-wip - Add type arguments to `Map` literals used for `Record` serialization. -- Added support for generating `ExampleJsonKeys`, exposing a secured way to - access the json keys from the properties. - ([#1164](https://github.com/google/json_serializable.dart/pull/1164)) +- Add support for `JsonSerializable(createJsonKeys: true)`. + ([#1401](https://github.com/google/json_serializable.dart/pull/1401)) - Handle decoding an `int` value from a `double` literal. This now matches the behavior of `double` values being encoded as `int`. diff --git a/json_serializable/README.md b/json_serializable/README.md index 5d30efd1..d30a1365 100644 --- a/json_serializable/README.md +++ b/json_serializable/README.md @@ -298,15 +298,15 @@ targets: [`Enum`]: https://api.dart.dev/stable/dart-core/Enum-class.html [`int`]: https://api.dart.dev/stable/dart-core/int-class.html [`Iterable`]: https://api.dart.dev/stable/dart-core/Iterable-class.html -[`JsonConverter`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html -[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum/valueField.html -[`JsonEnum`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum-class.html -[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html -[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html -[`JsonKey`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey-class.html -[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonLiteral-class.html -[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable-class.html -[`JsonValue`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonValue-class.html +[`JsonConverter`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonConverter-class.html +[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum/valueField.html +[`JsonEnum`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum-class.html +[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/fromJson.html +[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/toJson.html +[`JsonKey`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey-class.html +[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonLiteral-class.html +[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonSerializable-class.html +[`JsonValue`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonValue-class.html [`List`]: https://api.dart.dev/stable/dart-core/List-class.html [`Map`]: https://api.dart.dev/stable/dart-core/Map-class.html [`num`]: https://api.dart.dev/stable/dart-core/num-class.html