serializer 0.8.2

Build Status Coverage Status Pub version


No maintenance on this package anymore. Prefer to use build_value

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';

class MyModel {
    String name;

    //constructor need to be without parameters or with optional or positional.

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

    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();


    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:

  serializer: ^0.8.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter 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/serializer.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/src/core/api.dart. (-7.71 points)

Analysis of lib/src/core/api.dart reported 16 hints, including:

line 19 col 27: Unnecessary new keyword.

line 91 col 55: Use = to separate a named parameter from its default value.

line 91 col 81: Use = to separate a named parameter from its default value.

line 91 col 108: Use = to separate a named parameter from its default value.

line 99 col 12: Unnecessary new keyword.

Fix lib/src/core/annotations.dart. (-2.48 points)

Analysis of lib/src/core/annotations.dart reported 5 hints:

line 9 col 22: Avoid const keyword.

line 15 col 16: Avoid const keyword.

line 21 col 23: Avoid const keyword.

line 27 col 19: Avoid const keyword.

line 38 col 32: Avoid const keyword.

Fix lib/src/codecs/date_time_milliseconds.dart. (-0.50 points)

Analysis of lib/src/codecs/date_time_milliseconds.dart reported 1 hint:

line 10 col 7: Unnecessary new keyword.

Fix lib/src/codecs/date_time_seconds.dart. (-0.50 points)

Analysis of lib/src/codecs/date_time_seconds.dart reported 1 hint:

line 10 col 7: Unnecessary new keyword.

Format lib/src/codecs/object_id.dart.

Run dartfmt to format lib/src/codecs/object_id.dart.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: bson.

Package is getting outdated. (-54.25 points)

The package was last published 80 weeks ago.

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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

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

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.0 <3.0.0
bson any 0.3.2
Transitive dependencies
collection 1.14.12
fixnum 0.10.11
more 1.18.2 2.2.0