eredo / dartson

Dartson is a Dart library that can be used to convert Dart objects into a JSON string.
MIT License
79 stars 29 forks source link

Subclass doesn't decode parent fields #37

Closed mnordine closed 6 years ago

mnordine commented 8 years ago

Given the following file:

import 'package:dartson/dartson.dart';
import 'dart:convert' show JSON;

@Entity()
class Parent
{
  int id;
}

@Entity()
class Child extends Parent
{
  int blah;

  toString() => 'id: $id, blah: $blah';
}

main()
{
  final map = {
    'id': 0,
    'blah': 1
  };

  Child child = new Dartson.JSON().decode(JSON.encode(map), new Child());
  print(child);
}

It prints id: null, blah: 1

seanmccleary commented 8 years ago

Is this not a duplicate of #7 ?

eredo commented 6 years ago

Supported in 1.0.0-alpha