json_annotation 4.5.0 json_annotation: ^4.5.0 copied to clipboard
Classes and helper functions that support JSON code generation via the `json_serializable` package.
4.5.0 #
- Added
FieldRename.screamingSnake
.
4.4.0 #
- Added
JsonKey.readValue
. - Non-breaking updates to
checkedCreate
andcheckedConvert
to supportJsonKey.readValue
. - Improved
toString
in included exceptions.
4.3.0 #
- Changed the type of
JsonKey.unknownEnumValue
fromObject?
toEnum?
. Assuming this feature has been used correctly, it shouldn't be a breaking change. - Changed the type of the
$enumDecodeNullable
parameterunknownValue
fromObject?
toEnum?
.
4.2.0 #
- Added
JsonSerializable.constructor
field to allow specifying an alternative constructor to invoke when creating afromJson
helper. - Added
JsonEnum
for annotatingenum
types. - Added
$enumDecodeNullable
and$enumDecode
helpers to minimize generated code. - Added
const
JsonKey.nullForUndefinedEnumValue
for use inJsonKey.unknownEnumValue
when you want to usenull
for an unknown value. - Require Dart SDK
>=2.14.0
.
4.1.0 #
- Added a
const
constructor toJsonConverter
. - Added
$checkedCreate
helper that will be used bypackage:json_serializable
v5+ and replaces both$checkedNew
and$checkedConvert
. - Annotate annotations with the supported target types, to minimize incorrect usage.
4.0.1 #
- Fix a potential error with
checked: true
whenArgumentError.message
isnull
. - Updated
JsonSerializable.fromJson
to handlenull
values. - Deprecate
JsonSerializable
defaults
andwithDefaults()
.
4.0.0 #
- Support null safety.
- Requires Dart 2.12.
- Updated
$checkedConvert
helper to support null-safety. - Removed the
nullable
field onJsonKey
– the constructor entry still exists, but it's marked@Deprecated
. The nullability of a field is now determined by the Dart type system.
3.1.1 #
- Avoid
null
values forCheckedFromJsonException.message
by usingtoString()
with unrecognized error types. - Added a helpful
UnrecognizedKeysException.toString()
. - Fixed doc comments for
JsonSerializable.genericArgumentFactories
.
3.1.0 #
- Added
JsonSerializable.genericArgumentFactories
field. - Require at least Dart
2.7.0
.
3.0.1 #
- Require at least Dart
2.6.0
. - Fix lint that was affecting
pub.dev
score.
3.0.0 #
- BREAKING Removed
JsonSerializable.useWrappers
and associated$
-prefixed helpers. - BREAKING Removed
JsonSerializable.generateToJsonFunction
. - BREAKING Removed
encodeEmptyCollection
fromJsonSerializable
andJsonKey
. - Added
JsonSerializable.ignoreUnannotated
. - Added
JsonKey.unknownEnumValue
. - Require at least Dart
2.3.0
.
2.4.0 #
- Deprecate members that will be removed in
json_annotation
3.0.0
and that are not supported injson_serializable
3.0.0
.JsonSerializable.useWrappers
and associated$
-prefixed helpersJsonSerializable.generateToJsonFunction
,encodeEmptyCollection
fromJsonSerializable
andJsonKey
.
2.3.0 #
- Added
pascal
as an additionalfieldRename
option. - Require at least Dart
2.2.0
.
2.2.0 #
- Add an optional (named)
badKey
parameter and field toCheckedFromJsonException
.
2.1.0 #
-
Require at least Dart
2.1.1
. -
Added to
encodeEmptyCollection
toJsonKey
andJsonSerializable
. -
JsonSerializable.fromJson
now throwsCheckedFromJsonException
on errors. This is potentially a breaking change. -
Added a more helpful
toString
toCheckedFromJsonException
.
2.0.0 #
-
Potentially Breaking
JsonSerializable
no longer sets default values for fields when constructor arguments are unset ornull
. This is not likely an issue for developers using this class as an annotation with a compatible version ofpackage:json_serializable
, but it may cause issues if class is used in other contexts. -
Support all
build.yaml
configuration options on classes by adding a number of fields toJsonSerializable
:anyMap
,checked
,explicitToJson
,generateToJsonFunction
, anduseWrappers
.
1.2.0 #
- Added
JsonConverter
class to support custom conversion of types.
1.1.0 #
- Added the
fieldRename
option toJsonSerializable
and the associatedFieldRename
enum.
1.0.0 #
-
Added
JsonValue
class for annotatingenum
fields with a custom serialization value. -
Removed
$checkAllowedKeys
,$enumDecode
and$enumDecodeNullable
which are no longer needed by the latest release ofpackage:json_serializable
.
0.2.9+1 #
- Support the Dart 2.0 stable release.
0.2.9 #
- When
FormatException
is caught in "checked mode", use themessage
property when creatingCheckedFromJsonException
.
0.2.8 #
-
Added
$checkKeys
helper function and deprecated$checkAllowedKeys
. Upgrading to the latestjson_serializable
and re-running your build will eliminate any@deprecated
hints you see. -
Added
BadKeyException
exception which is the abstract super class forMissingRequiredKeysException
,UnrecognizedKeysException
, andDisallowedNullValueException
. -
Added
JsonKey.required
field and an associatedMissingRequiredKeysException
that is thrown whenrequired
fields don't have corresponding keys in a source JSON map. -
Added
JsonKey.disallowNullValue
field and an associatedDisallowedNullValueException
that is thrown when corresponding keys exist in a source JSON map, but their values arenull
. -
Updated documentation of
JsonSerializable.createToJson
to include details of the newgenerate_to_json_function
configuration option.
0.2.7+1 #
- Small improvement to
UnrecognizedKeysException.message
output and documentation comments.
0.2.7 #
- Added
JsonSerializable.disallowUnrecognizedKeys
.- Added a helper function to support this option. This function starts with a
$
and should only be referenced by generated code. It is not meant for direct use. - Added
UnrecognizedKeysException
for reporting errors.
- Added a helper function to support this option. This function starts with a
0.2.6 #
-
CheckedFromJsonException
- Added a public constructor to support hand-written JSON decoding logic.
- The
message
property is nowString
(instead ofObject
).
-
Added
JsonKey.defaultValue
. -
Added helpers for deserialization of
enum
values. These functions starting with$
are referenced by generated code. They are not meant for direct use.
0.2.5 #
-
Added
CheckedFromJsonException
which is thrown by code generated whenchecked
is enabled injson_serializable
. -
Added functions to support the
checked
generation option. These functions starting with$
are referenced by generated code. They are not meant for direct use.
0.2.4 #
- Added
fromJson
andtoJson
fields toJsonKey
class.
0.2.3 #
- Added
ignore
field toJsonKey
class annotation
0.2.2 #
- Added a helper class –
$JsonMapWrapper
– and helper functions –$wrapMap
,$wrapMapHandleNull
,$wrapList
, and$wrapListHandleNull
– to support theuseWrappers
option added toJsonSerializableGenerator
inv0.3.0
ofpackage:json_serializable
.
0.2.1 #
JsonSerializable
class annotation- Added
nullable
field. - Fixed doc comment.
- Added
0.2.0 #
- Moved annotation classes for
JsonSerializable
andJsonLiteral
.