johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de.INVALID>
Subject do we like to support 'implicit converters' ?
Date Fri, 10 Nov 2017 08:53:02 GMT
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
Mime
View raw message