json_factory_runtime_generator 0.3.2
json_factory_runtime_generator: ^0.3.2 copied to clipboard
Build-time JSON factory generator for json_serializable classes. Decodes JSON to the right class from a key in the JSON, with no base class, mixin or toJson changes.
0.3.2 #
- No code changes. Republished so pub.dev can verify the repository link, which 0.3.1 pointed at before the matching pubspec was on GitHub.
0.3.1 #
- The build stops when
@JsonFactoryKeyis on a method, getter or field. It was ignored, which left the class unregistered. - The build stops when a class with
@JsonFactoryKeyextends a class with a@jsonFactoryKeyfield. ItstoJson()wrote the parent's key, so the JSON decoded back to the parent.
0.3.0 #
@JsonFactoryKey('key')registers a class with no key field. ItstoJson()doesn't write the key, so usetoJsonForFactory.- Each mixin and mapper gets
toJsonForFactory(object), which adds the key for the exact type ofobject. It works for classes using either annotation. - The aggregator now runs before
json_serializable, so@JsonKey(toJson: JsonFactoryMapper.toJsonForFactory)can resolve the mapper. - The generated file also imports the registered classes' own libraries.
- Requires
json_factory_runtime_annotation0.3.0.
0.2.0 #
- Breaking: the default mixin is now
JsonFactoryMixin(wasJsonFactoryMapper). Replacewith JsonFactoryMapperwithwith JsonFactoryMixin, or call the new static class instead. - Each mixin gets a static mapper class, so no wrapper class is needed:
JsonFactoryMapper.fromKeyedJsonAs<User>(json). A trailingMixinin the mixin name becomesMapper(ApiMixin→ApiMapper); other names getMapperappended.instanceholds the mixin as aconstobject. The build stops if a mapper name clashes with a mixin name or another mapper. - Breaking:
@jsonFactoryKeygoes on afinal Stringfield initialized with a string literal. ReplaceString get factoryKey => 'user';withfinal String factoryKey = 'user';. Getters now stop the build. @jsonFactoryKeyis also accepted on a final enum field initialized with a constant that has a string@JsonValue.- The build stops when a concrete
@JsonSerializablesubclass of a registered class has no@jsonFactoryKeyfield of its own. - A class with a
@jsonFactoryKeyfield but nofromJsonof its own uses the nearest superclass'sfromJson. - Works with
build4.0.11+ andsource_gen4.2.4+ as well, for projects that also use builders not yet onbuild5. - Requires
json_factory_runtime_annotation0.2.0.
0.1.0 #
- Initial release.