serializer 0.5.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

Build Status Coverage Status Pub 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.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

example/serializer.dart

export 'package:serializer/serializer_reflectable.dart';
//export 'package:serializer/serializer_codegen.dart';
export 'package:serializer/codecs.dart';

Use this package as a library

1. Depend on it

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


dependencies:
  serializer: "^0.5.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:serializer/build.dart';

      import 'package:serializer/codecs.dart';

      import 'package:serializer/core.dart';

      import 'package:serializer/serializer_codegen.dart';

      import 'package:serializer/serializer_reflectable.dart';
  
Version Uploaded Documentation Archive
0.7.1 Sep 12, 2017 Go to the documentation of serializer 0.7.1 Download serializer 0.7.1 archive
0.7.0 Aug 22, 2017 Go to the documentation of serializer 0.7.0 Download serializer 0.7.0 archive
0.6.2+1 Aug 14, 2017 Go to the documentation of serializer 0.6.2+1 Download serializer 0.6.2+1 archive
0.6.2 Aug 14, 2017 Go to the documentation of serializer 0.6.2 Download serializer 0.6.2 archive
0.6.1 May 5, 2017 Go to the documentation of serializer 0.6.1 Download serializer 0.6.1 archive
0.6.0 Mar 24, 2017 Go to the documentation of serializer 0.6.0 Download serializer 0.6.0 archive
0.5.1 Dec 13, 2016 Go to the documentation of serializer 0.5.1 Download serializer 0.5.1 archive
0.5.0+1 Nov 1, 2016 Go to the documentation of serializer 0.5.0+1 Download serializer 0.5.0+1 archive
0.5.0 Nov 1, 2016 Go to the documentation of serializer 0.5.0 Download serializer 0.5.0 archive
0.4.3 Aug 28, 2016 Go to the documentation of serializer 0.4.3 Download serializer 0.4.3 archive

All 28 versions...

Analysis

We analyzed this package on Jun 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
62 / 100
Health:
Code health derived from static analysis. [more]
81 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
33 / 100
Overall score:
Weighted score of the above. [more]
62
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

Platform components identified in package: build.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 20 errors 25 hints.

    Strong-mode analysis of lib/codegen/builder.dart failed with the following error:

    line: 98 col: 19
    The getter 'logger' isn't defined for the class 'BuildStep'.

    Strong-mode analysis of lib/codegen/generator.dart failed with the following error:

    line: 64 col: 32
    The getter 'input' isn't defined for the class 'BuildStep'.

    Similar analysis of the following files failed:

    • lib/build.dart (hint)
    • lib/codecs/date_time.dart (hint)
    • lib/codecs/date_time_milliseconds.dart (hint)
    • lib/codecs/date_time_seconds.dart (hint)
    • lib/codecs/date_time_utc.dart (hint)
    • lib/codecs/object_id.dart (hint)
    • lib/codecs/type_codec.dart (hint)
    • lib/codegen/annotations.dart (hint)
    • lib/codegen/api.dart (hint)
    • lib/core.dart (hint)
    • lib/core/api.dart (hint)
    • lib/reflectable/annotations.dart (hint)
    • lib/reflectable/api.dart (hint)
    • lib/reflectable/convert.dart (hint)
    • lib/serializer_codegen.dart (hint)
    • lib/serializer_reflectable.dart (hint)
  • Package is getting outdated.

    The package was released 85 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
bson ^0.2.0 0.2.0 0.3.1
reflectable ^1.0.0 1.0.4 2.0.1
source_gen ^0.5.0 0.5.10+1 0.8.2
Transitive dependencies
analyzer 0.30.0+4 0.32.1
args 1.4.3
async 2.0.7
barback 0.15.2+16
build 0.9.3 0.12.6
charcode 1.1.1
cli_util 0.1.3
code_transformers 0.5.1+5
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
dart_style 1.0.9+1 1.1.0
fixnum 0.10.7
front_end 0.1.0-alpha.4.1 0.1.1
glob 1.1.5
html 0.13.3+1
isolate 1.1.0 2.0.1
kernel 0.3.0-alpha.1.1 0.3.1
logging 0.11.3+1
meta 1.1.5
more 1.9.0
package_config 1.0.3
path 1.4.2 1.6.1
plugin 0.2.0+2
pool 1.3.5
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
yaml 2.1.14
Dev dependencies
browser ^0.10.0
test ^0.12.0