androidlogan-square

LoganSquare not including field name on generated Json


I have a class DbRecord

public class DbRecord {


    @JsonField(name="on_duties")
    List<OnDutyElement> onDuties;

    @JsonField(name = "date_time")
    DateTime dateTime;

When I try to serialize an object of this class, the LoganSquare doesn't include the dateTime field.

Generated JSON: {:"2015-12-21T11:32:17.503-05:00","on_duties":[{...everything normal from here


Solution

  • Probably, there is a bug. Write your own TypeConverter that extends DateTypeConverter, override serialize() method explicit pass writeFieldName with value true.

    This will force the type converter write field name to the writer.