json解析,json属性带特殊符号,ObjectMapper.ReadValue的方式

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

ObjectMapper mapper = new ObjectMapper();

mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.enable(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS);

Tmp tmp = mapper.readValue(jsonString, Tmp.class);

Tmp

{

    @JsonProperty("provider:segmentation_id")
     private int segmentation_id;

}

猜你喜欢

转载自lincy-521.iteye.com/blog/2289529