what's the difference with the two objectmappers. com.fasterxml.jackson.databind.ObjectMapper

584 views
Skip to first unread message

Eone Zhang

unread,
Jun 6, 2014, 8:58:49 AM6/6/14
to jackso...@googlegroups.com
what's the difference with the two objectmappers.
com.fasterxml.jackson.databind.ObjectMapper
org.codehaus.jackson.map.ObjectMapper


I configured the org.codehaus.jackson.map.ObjectMapper mapper like this;
    mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);

but how can I achieve the same result with the new Mapper(com.fasterxml.jackson.databind.ObjectMapper),
now I configured the new mapper like this:
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

is there an alternative way to config  ALLOW_SINGLE_QUOTES and Inclusion.NON_NULL options for the mapper of com.fasterxml.jackson.databind.ObjectMapper

I want to use com.fasterxml.jackson.databind.ObjectMapper because of the data-bind api, but I still want to be compatible the program that use org.codehaus.jackson.map.ObjectMapper. the client can send json string without quotes(such as {username:'',password:''})



Reply all
Reply to author
Forward
0 new messages