serializer 0.1.6 copy "serializer: ^0.1.6" to clipboard
serializer: ^0.1.6 copied to clipboard

outdatedDart 1 only

Serialization to JSON using reflectable

example/serializer_example.dart

// Copyright (c) 2016, <your name>. 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 Serialize {
  String city, country;

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

main() async {
  await initSerializer();

  ModelA a = new ModelA("toto", 15);
  ModelB b = new ModelB("Paris", "France");

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

  print(Serializer.toJson(a));
  print(Serializer.toMap(a));

  ModelA A = Serializer.fromJson(Serializer.toJson(a), ModelA);

  print(Serializer.toJson(A));

}
1
likes
0
pub points
14%
popularity

Publisher

unverified uploader

Serialization to JSON using reflectable

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

reflectable

More

Packages that depend on serializer