Below is the relevant method. One of the properties is of LocalDate (Joda).
@ApiMethod(
name = "taxforms.get",
path = "tax-forms",
httpMethod = ApiMethod.HttpMethod.GET
)
public TaxDataList retrieveTaxDataList(
HttpServletRequest httpServletRequest
) {
TaxDataList taxDataList = new TaxDataList( );
TaxData taxData = SampleTax.sampleTaxData( "Tax1098" );
taxDataList.addFormsItem( taxData );
return taxDataList;
}
If I do my own serialization, my code includes this:
ObjectMapper objectMapper = new ObjectMapper( );
// Special handling for dates
objectMapper.registerModule( new JodaModule( ) );
objectMapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS );
objectMapper.writeValue( sw, data );
json = sw.toString( );
How can I customize the way the framework does the serialization?
This is a close sample code to what you want and which uses transforms java LocalDate and Instant classes into strings and numbers: