serializer 0.3.0

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

Build Status Coverage Status Pub version

Serializer

Serialize and Deserialize Dart Object with reflectable

Codecs supported:

  • Json

Example

import 'package:serializer/serializer.dart';

@serializable
class MyModel {
    String name;

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

main() {
    Serializer serializer = new Serializer.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.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_example.dart

// Copyright (c) 2016, the Serializer project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library serializer.example;

import 'package:serializer/serializer.dart';

@serializable
class ModelA {
  String name;
  num age;

  ModelA([this.name, this.age]);
}

@serializable
class ModelB extends JsonObject {
  String city, country;

  ModelB([this.city, this.country]);
}

@serializable
class ModelC extends JsonObject {
  String name, password;

  @ignore
  int age;

  ModelC([this.name, this.password, this.age]);
}

main() {
  ModelA a = new ModelA("toto", 15);
  ModelB b = new ModelB("Paris", "France");
  ModelC c = new ModelC("Alice", "ThereIsNone", 42);

  print(b.toJson());
  print(b.toMap());
  print(c.toJson());

  var sz = TypedJsonObject.serializer;
  print(sz.toMap(a));
  print(sz.encode(a));

  ModelA A = sz.decode(sz.encode(a));
  print(sz.encode(A));
}

Use this package as a library

1. Depend on it

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


dependencies:
  serializer: ^0.3.0

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/serializer.dart';
  
Version Uploaded Documentation Archive
0.8.2 Jul 29, 2018 Go to the documentation of serializer 0.8.2 Download serializer 0.8.2 archive
0.8.1 Jul 18, 2018 Go to the documentation of serializer 0.8.1 Download serializer 0.8.1 archive
0.8.0 Jul 6, 2018 Go to the documentation of serializer 0.8.0 Download serializer 0.8.0 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

All 31 versions...

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

This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0