If we add one we must align on the JAXRS (and few other libs) standard which is toString() vs constructor(string)/static parse(String)/static of(String) from memory. We can already set a converter so not sure it has much value but I see - as you - all the pitfalls and errors it can create so -0 from me.
Romain Manni-Bucau @rmannibucau | Blog | Old Blog | Github | LinkedIn 2017-11-10 9:53 GMT+01:00 Mark Struberg <[email protected]>: > Hi folks! > > > If a JSON String is to be converted to a target type and no specific > Converter can be found, a FallbackConverter is used in MappingParserImpl. > > We could theoretically improve the JSON->Java mapping this with the following > logic > > * if Enum -> valueOf() (this part exists already) > * The target type T has a Constructor with a String parameter, or > * the target type T has a static T valueOf(String) method with th, or > * the target type T has a static T parse(String) method. > > To be honest, I'm not really sure. > Because it is not symmetric. > Because how would the Java->JSON mapping work? > Is there any implicit converter we could use? > toString() certainly not as it is available in every Object. So how can we > know when to iterate into the objects getters or use toString() as converter? > Imo not possible. > > Any good ideas? > > LieGrue, > strub
