serializer_generator 0.8.2

Build Status Coverage Status Pub version

DISCLAIMER

No maintenance on this package anymore. Prefer to use jaguar_serializer

Documentation aren't aligned with last version.

Serializer #

Serialize and Deserialize Dart Object with reflectable or codegen

Codecs supported: #

  • Json

Example #

import 'package:serializer/serializer_reflectable.dart';

@serializable
class MyModel {
    String name;

    //constructor need to be without parameters or with optional or positional.
    MyModel([this.name]);
}

main() {
    Serializer serializer = new ReflectableSerializer.Json();
    
    //serialize
    MyModel model = new MyModel("John", 24);
    String json = serializer.encode(model);
    Map jsonMap = serializer.toMap(model);

    //deserialize
    model = serializer.decode(json, MyModel);
    model = serializer.fromMap(jsonMap, MyModel);
 }

Documentations #

Changelog #

0.6.0 #

Breaking changes:

  • Remove reflectable version
  • Update 'source_gen' to 0.5.4+2

0.5.1 #

  • Fix int/double/num conversion

0.5.0 #

  • Update reflectable to 1.0.0

Breaking changes:

  • Split the serializer in 2 versions:
    • codegen
    • reflectable
  • Add @UseType annotation only for codegen
  • Same API, change import to switch mode

Example #

    import "package:serializer/serializer_codegen.dart";
    Serializer ser = new CodegenSerializer.json();

or

    import "package:serializer/serializer_reflectable.dart";
    Serializer ser = new ReflectableSerializer.json();

0.4.3 #

  • Add DateTime codecs for seconds and milliseconds since epoch.
  • Add dynamic type serialization.
  • Add SerializedWithTypeInfo annotation to set typeInfo at the object's root.
  • withTypeInfo flag into Serializer methods only sets typeInfo at the object's root.

Breaking changes:

  • Fix coding style for Serializer factories.

0.4.2 #

Breaking changes:

  • Add useTypeInfo boolean to Serializer constructor.
  • Replace optional parameters with named parameters into Serializer methods.
  • useTypeInfo flag into Serializer methods could overidde the global useTypeInfo from instance.

0.4.1+1 #

  • fix decode when content is already decode.

0.4.1 #

  • Add toPrimaryObject method
  • fix some error with null

0.4.0+1 #

  • Minor fix when some value are Null.
  • Don't serialize static and const field

0.4.0 #

  • Add DateTimeUtcCodec an UTC DateTime codec.
  • Add ObjectId a simple ObjectId codec (for Mongo BSON).

Breaking changes:

  • Move codecs/codec.dart to codecs.dart
  • In class Serialize, serializer getter is no more static.
  • Remove DateTimeCodec from Serializer.Json and Serializer.TypedJson factories

0.3.2 #

  • Support cyclical objects (@referenceable & @reference annotations)
  • Support SerializedName class inheritance

0.3.1 #

  • Support mixins

0.3.0 #

  • type_info_key is now optional

Breaking changes:

  • no initSerializer function anymore, instead, you have to instanciate a serializer classe
    • Serializer serializer = new Serializer.Json();
  • toJson and fromJson replace by encode and decode
    • see doc for more infos

0.2.0 #

  • type_info_key is now parametrable
  • json output is now simpler

0.1.0 #

  • Basic JSON serialization and desarialization

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  serializer_generator: ^0.8.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:serializer_generator/serializer_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
24
Overall:
Weighted score of the above. [more]
43
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: other

Primary library: package:serializer_generator/serializer_generator.dart with components: io, isolate, build, mirrors.

Health suggestions

Fix lib/src/generator.dart. (-0.50 points)

Analysis of lib/src/generator.dart reported 1 hint:

line 471 col 10: Don't explicitly initialize variables to null.

Maintenance issues and suggestions

Support latest dependencies. (-50 points)

The version constraint in pubspec.yaml does not support the latest published versions for 5 dependencies (analyzer, build, build_config, build_runner, source_gen).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-6.30 points)

The package was last published 55 weeks ago.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and serializer_generator.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.0 <3.0.0
analyzer ^0.32.3 0.32.6 0.38.1
build ^0.12.7 0.12.7+3 1.1.6
build_config ^0.3.1 0.3.2 0.4.1+1
build_runner ^0.9.1 0.9.2 1.6.7
serializer ^0.8.0 0.8.2
source_gen ^0.8.3 0.8.3+1 0.9.4+4
Transitive dependencies
args 1.5.2
async 2.3.0
build_resolvers 0.2.2+7 1.0.7
build_runner_core 0.2.2+2 3.0.9
built_collection 4.2.2
built_value 6.7.0
charcode 1.1.2
cli_util 0.1.3+2
code_builder 3.2.0
collection 1.14.12
convert 2.1.1
crypto 2.1.2
csslib 0.16.1
dart_style 1.1.3 1.2.10
fixnum 0.10.9
front_end 0.1.4+2 0.1.23
glob 1.1.7
graphs 0.1.3+1 0.2.0
html 0.14.0+2
http_multi_server 2.1.0
http_parser 3.1.3
io 0.3.3
json_annotation 1.2.0 3.0.0
kernel 0.3.4+2 0.3.23
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
more 1.18.0
package_config 1.1.0
path 1.6.4
pedantic 1.8.0+1
plugin 0.2.0+3
pool 1.4.0
pub_semver 1.4.2
pubspec_parse 0.1.4 0.1.5
quiver 2.0.5
shelf 0.7.5
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 0.0.19
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.1.16
Dev dependencies
bson ^0.3.1 0.3.2
test ^1.2.0