If all JSON Field names are lowercase with underscore you can define fieldNamingPolicy like that.
@JsonObject(fieldNamingPolicy = JsonObject.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
public class DbRecord {
@JsonField
List<OnDutyElement> onDuties;
@JsonField
DateTime dateTime;
You need also to have TypeConverter for DateTime if you haven't done that already, LoganSquare allows you now to define the TypeConverter in the JsonField Annotation like that
@JsonField(typeConverter = DateTimeConverter.class)
DateTime time;
and the DateTimeConverter
public class DateTimeConverter implements TypeConverter<DateTime> {
@Override
public DateTime parse(JsonParser jsonParser) throws IOException {
String dateString = jsonParser.getValueAsString(null);
try {
DateTime dateTime = new DateTime(dateString);
return dateTime.changeTimeZone(TimeZone.getTimeZone("UTC"), TimeZone.getDefault());
} catch (RuntimeException runtimeException) {
runtimeException.printStackTrace();
return null;
}
}
@Override
public void serialize(DateTime object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStringField(fieldName, object.format("YYYY-MM-DDThh:mm:ss"));
}
}