added convertAcceptStringAsNull
This commit is contained in:
parent
a45afc6424
commit
0b416cfcda
|
@ -87,6 +87,13 @@ public class Serialization {
|
||||||
public static final <T> T convert(Object d,Class<T> clazz){
|
public static final <T> T convert(Object d,Class<T> clazz){
|
||||||
return mapper.convertValue(d,clazz);
|
return mapper.convertValue(d,clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final <T> T convertAcceptStringAsNull(Object d,Class<T> clazz){
|
||||||
|
mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,true);
|
||||||
|
T converted = mapper.convertValue(d,clazz);
|
||||||
|
mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,false);
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
|
||||||
public static final Document asDocument(Object obj) throws JsonProcessingException {
|
public static final Document asDocument(Object obj) throws JsonProcessingException {
|
||||||
return Document.parse(mapper.writeValueAsString(obj));
|
return Document.parse(mapper.writeValueAsString(obj));
|
||||||
|
|
Loading…
Reference in New Issue