I have this hierarchy of classes (here simplified). Once Ref was a normal class but not its abstract, and as you see it has a @Field() annotation.
class Resp
{
@Field() String error;
}
class DbObj extends Resp
{
@Id() String id;
}
abstract class Ref extends DbObj
{
@Field() String get href;
}
abstract class Vista extends Ref
{
String get icon;
}
class NormalVista extends Ref implements Vista
{
@Field() String get icon => "algo";
@Field() String get href => "someHost/$id";
}
For some strange reason when encoding NormalVista I was getting href with the id included but not the id field itself in the JSON. It had to be there because href showed it, but the mapper wasn't including it.
The error is solved by removing the @Field() annotation from href in Ref, but its not obvious because in many cases it works, just that in this particular setup it doesn't.
I have this hierarchy of classes (here simplified). Once
Ref
was a normal class but not its abstract, and as you see it has a@Field()
annotation.For some strange reason when encoding
NormalVista
I was gettinghref
with the id included but not theid
field itself in the JSON. It had to be there becausehref
showed it, but the mapper wasn't including it.The error is solved by removing the
@Field()
annotation fromhref
inRef
, but its not obvious because in many cases it works, just that in this particular setup it doesn't.