Java annotation to transform a json field -


i trying come interface has pretty non-standard way of representing fields fed legacy system, interface seems require custom validations + transformations such

  • truncating string value beyond specified length (example : in cases truncate string beyond 25th character, in other cases truncate beyond 15th character)
  • validate string date field of format yyymmdd , transforming date field of yyyy-mm-dd format in setter

how come custom annotations can using @interface? able find @constraint(validatedby=someclass.class) there doesn't seem transform data (or sorry if haven't looked enough).. pointers on helpful.

in java, use "transformed" datatype in jackson annotated objects, example:

 private transformeddata data; 

then configure jackson deserializer accepts string , returns "transformeddata" object. when jackson trying fill in data field, notice needs conversion , call deserializer.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -