Dubbo Jackson serialization instructions

Jackson serialization provides support for serialization of primitive data types and simple beans, as well as support for class inheritance.

Data types that have been tested include:

Boolean/boolean
Long/long
Integer/int
Double/double
Short/short
Float/float
Byte/byte
java.util.Date
org.joda.time.DateTime

As well as arrays and beans composed of these basic data types, such as int[], String[], etc.

use of jackson serialization

<dubbo:protocol name="dubbo" port="20880" serialization="jackson" />

Custom ObjectMapper

By default, the ObjectMapper used by Jackson to serialize and deserialize is defined as follows:

  @Override
    public ObjectMapper getObjectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//            objectMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
        objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        objectMapper.setTimeZone(TimeZone.getDefault());
        return objectMapper;
}

If you need to customize the JacksonObjectMapperProvider, the developer can customize it by implementing the com.alibaba.dubbo.common.json.JacksonObjectMapperProvider interface, and add the file com.alibaba.dubbo.common.json.JacksonObjectMapperProvider in /META-INF/dubbo/ , the content example is as follows:

jackson=com.alibaba.dubbo.examples.jackson.jacksonprovider.CustomJacksonObjectMapperProvider

Known Issues

  1. Does not support serialization of generic objects, such as List, Map type serialization and deserialization

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326565445&siteId=291194637