json_serializable 1.0.1
json_serializable: ^1.0.1 copied to clipboard
Generates utilities to aid in serializing to/from JSON.
1.1.0 #
- Explicit
newandconstare no longer generated.
1.0.0 #
-
BREAKING By default, code generated to support
toJsonnow creates a top-level function instead of a mixin. The default for thegenerate_to_json_functionis nowtrue. To opt-out of this change, setgenerate_to_json_functiontofalse. -
Now supports changing the serialized values of enums using
JsonValue.enum AutoApply { none, dependents, @JsonValue('all_packages') allPackages, @JsonValue('root_package') rootPackage } -
JsonSerializableGenerator.generateForAnnotatedElementnow returnsIterable<String>instead ofString. -
SerializeContextandDeserializeContextnow have anaddMemberfunction which allowsTypeHelperinstances to add additional members when handling a field. This is useful for generating shared helpers, for instance. -
BREAKING The
headeroption is no longer supported and must be removed frombuild.yaml. -
If a manual build script is used the
json_serializablebuilder must be switched tohideOutput: true, and thecombiningBuilderfromsource_genmust be included following this builder. When using a generated build script withpub run build_runnerorwebdevthis is handled automatically.
0.5.8+1 #
- Support the Dart 2.0 stable release.
0.5.8 #
-
Small fixes to support Dart 2 runtime semantics.
-
Support serializing types provided by platform-specific libraries (such as Flutter) if they use custom convert functions.
0.5.7 #
-
Added support for
JsonKey.required.- When
true, generated code throws aMissingRequiredKeysExceptionif the key does not exist in the JSON map used to populate the annotated field. - Will be captured and wrapped in a
CheckedFromJsonExceptionifcheckedis enabled injson_serializable.
- When
-
Added
JsonKey.disallowNullValue.- When
true, generated code throws aDisallowedNullValueExceptionif the corresponding keys exist in in the JSON map, but it's value is null. - Will be captured and wrapped in a
CheckedFromJsonExceptionifcheckedis enabled injson_serializable.
- When
-
Added support for
Uriconversion. -
Added missing
checkedparameter to theJsonSerializableGenerator.withDefaultHelpersconstructor. -
Added
explicit_to_jsonconfiguration option.- See
JsonSerializableGenerator.explicitToJsonfor details.
- See
-
Added
generate_to_json_functionconfiguration option.- See
JsonSerializableGenerator.generateToJsonFunctionfor details.
- See
0.5.6 #
- Added support for
JsonSerializable.disallowUnrecognizedKeys.- Throws an
UnrecognizedKeysExceptionif it finds unrecognized keys in the JSON map used to populate the annotated field. - Will be captured and wrapped in a
CheckedFromJsonExceptionifcheckedis enabled injson_serializable.
- Throws an
- All
fromJsonconstructors now use block syntax instead of fat arrows.
0.5.5 #
-
Added support for
JsonKey.defaultValue. -
enumdeserialization now uses helpers provided byjson_annotation. -
Small change to how nullable
Mapvalues are deserialized. -
Small whitespace changes to
JsonLiteralgeneration to align withdartfmt. -
Improve detection of
toJsonandfromJsonin nested types.
0.5.4+1 #
- Fixed a bug introduced in
0.5.4in some cases where enum values are nested in collections.
0.5.4 #
-
Add
checkedconfiguration option. Iftrue, generatedfromJsonfunctions include extra checks to validate proper deserialization of types. -
Added
any_mapto configuration. AllowsfromJsoncode to support dynamicMapinstances that are not explicitlyMap<String, dynaimc>. -
Added support for classes with type arguments.
-
Use
Map.mapfor more map conversions. Simplifies generated code and fixes a subtle issue when theMapkey type isdynamicorObject.
0.5.3 #
-
Require the latest version of
package:analyzer-v0.32.0. -
If
JsonKey.fromJsonfunction parameter isIterableorMapwith type arguments ofdynamicorObject, omit the arguments when generating a cast._myHelper(json['key'] as Map)instead of_myHelper(json['key'] as Map<dynamic, dynamic>). -
JsonKey.fromJson/.toJsonnow support functions with optional arguments.
0.5.2 #
- If
JsonKey.fromJson/toJsonare set, apply them before any custom or defaultTypeHelperinstances. This allows customDateTimeparsing, by preempting the existingDateTimeTypeHelper.
0.5.1 #
-
Support new
fromJsonandtoJsonfields onJsonKey. -
Use
logexposed bypackage:build. This requires end-users to have at leastpackage:build_runner^0.8.2. -
Updated minimum
package:source_gendependency to0.8.1which includes improved error messages.
0.5.0 #
-
BREAKING Removed deprecated support for
require_library_directive/requireLibraryDirectiveinbuild_runnerconfiguration. -
BREAKING Removed the deprecated
generators.dartlibrary. -
BREAKING Removed
jsonPartBuilderfunction from public API. -
Support the latest
package:source_gen. -
Private and ignored fields are now excluded when generating serialization and deserialization code by using
@JsonKey(ignore: true). -
Throw an exception if a private field or an ignored field is referenced by a required constructor argument.
-
More comprehensive escaping of string literals.
package:json_serializable/type_helper.dart #
-
Breaking The
nullableparameter onTypeHelper.serializeand.deserializehas been removed. It is now exposed inSerializeContextandDeserializeContextabstract classes as a read-only property. -
Potentially Breaking The
metadataproperty onSerializeContextandDeserializeContextis now readonly. This would potentially break code that extends these classes – which is not expected.
0.4.0 #
-
Potentially Breaking Inherited fields are now processed and used when generating serialization and deserialization code. There is a possibility that the generated code may change in undesired ways for classes annotated for
v0.3. -
Avoid unnecessary braces in string escapes.
-
Use single quotes when generating code.
0.3.2 #
- The
require_library_directiveoption now defaults tofalse. The option will be removed entirely in0.4.0.
0.3.1+2 #
- Support the latest version of the
analyzerpackage.
0.3.1+1 #
- Expanded
package:buildsupport to allow version0.12.0.
0.3.1 #
-
Add a
build.yamlso the builder can be consumed by users ofbuild_runnerversion 0.7.0. -
Now requires a Dart
2.0.0-devrelease.
0.3.0 #
-
NEW top-level library
json_serializable.dart.-
Replaces now deprecated
generators.dartto accessJsonSerializableGeneratorandJsonLiteralGenerator. -
Adds the
jsonPartBuilderfunction to make it easy to create aPartBuilder, without creating an explicit dependency onsource_gen.
-
-
BREAKING
UnsupportedTypeErroradded a new required constructor argument:reason. -
BREAKING The deprecated
annotations.dartlibrary has been removed. Usepackage:json_annotationinstead. -
BREAKING The arguments to
TypeHelperserializeanddeserializehave changed.SerializeContextandDeserializeContext(new classes) are now passed instead of theTypeHelperGeneratortypedef (which has been deleted).
-
JsonSerializableGeneratornow supports an optionaluseWrappersargument when generates and uses wrapper classes to (hopefully) improve the speed and memory usage of serialization – at the cost of more code.NOTE:
useWrappersis not guaranteed to improve the performance of serialization. Benchmarking is recommended. -
Make
nullfield handling smarter. If a field is classified as notnullable, then use this knowledge when generating serialization code – even ifincludeIfNullisfalse.
0.2.5 #
-
Throw an exception if a duplicate JSON key is detected.
-
Support the
nullablefield on theJsonSerializableclass annotation.
0.2.4+1 #
- Throw a more helpful error when a constructor is missing.
0.2.4 #
-
Moved the annotations in
annotations.darttopackage:json_annotations.- Allows package authors to release code that has the corresponding annotations without requiring package users to inherit all of the transitive dependencies.
-
Deprecated
annotations.dart.
0.2.3 #
- Write out
toJsonmethods more efficiently when the first fields written are not intercepted by the null-checking method.
0.2.2+1 #
-
Simplify the serialization of
Mapinstances when no conversion is required forvalues. -
Handle
intliterals in JSON being assigned todoublefields.
0.2.2 #
- Enable support for
enumvalues. - Added
asConsttoJsonLiteral. - Improved the handling of Dart-specific characters in JSON strings.
0.2.1 #
- Upgrade to
package:source_genv0.7.0
0.2.0+1 #
- When serializing classes that implement their own
fromJsonconstructor, honor their constructor parameter type.
0.2.0 #
-
BREAKING Types are now segmented into their own libraries.
-
package:json_serializable/generators.dartcontainsGeneratorimplementations. -
package:json_serializable/annotations.dartcontains annotations. This library should be imported with your target classes. -
package:json_serializable/type_helpers.dartcontainsTypeHelperclasses and related helpers which allow custom generation for specific types.
-
-
BREAKING Generation fails for types that are not a JSON primitive or that do not explicitly supports JSON serialization.
-
BREAKING
TypeHelper:-
Removed
canmethods. Returnnullfrom(de)serializeif the provided type is not supported. -
Added
(de)serializeNestedarguments to(de)serializemethods allowing generic types. This is how support forIterable,List, andMapis implemented.
-
-
BREAKING
JsonKey.jsonNamewas renamed tonameand is now a named parameter. -
Added support for optional, non-nullable fields.
-
Added support for excluding
nullvalues when generating JSON. -
Eliminated all implicit casts in generated code. These would end up being runtime checks in most cases.
-
Provide a helpful error when generation fails due to undefined types.
0.1.0+1 #
- Fix homepage in
pubspec.yaml.
0.1.0 #
-
Split off from source_gen.
-
Add
/* unsafe */comments to generated output likely to be unsafe. -
Support (de)serializing values in
Map. -
Fix ordering of fields when they are initialized via constructor.
-
Don't use static members when calculating fields to (de)serialize.



