本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonInclude.Include方法的典型用法代码示例。如果您正苦于以下问题:Java JsonInclude.Include方法的具体用法?Java JsonInclude.Include怎么用?Java JsonInclude.Include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.annotation.JsonInclude
的用法示例。
在下文中一共展示了JsonInclude.Include方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JsonTools
import com.fasterxml.jackson.annotation.JsonInclude; //导入方法依赖的package包/类
public JsonTools(JsonInclude.Include include) {
mapper = new ObjectMapper();
// 设置输出时包含属性的风格
if (include != null) {
mapper.setSerializationInclusion(include);
}
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
SimpleModule javaTimeModule = new SimpleModule();
javaTimeModule.addSerializer(Date.class, new JsonDateSerializer());
javaTimeModule.addDeserializer(Date.class, new JsonDateDeserializer());
mapper.registerModule(javaTimeModule);
}
示例2: setSerializationInclusion
import com.fasterxml.jackson.annotation.JsonInclude; //导入方法依赖的package包/类
/**
* Set a custom inclusion strategy for serialization.
* @see com.fasterxml.jackson.annotation.JsonInclude.Include
*/
public void setSerializationInclusion(JsonInclude.Include serializationInclusion) {
this.serializationInclusion = serializationInclusion;
}
示例3: getInclude
import com.fasterxml.jackson.annotation.JsonInclude; //导入方法依赖的package包/类
JsonInclude.Include getInclude();
示例4: setInclude
import com.fasterxml.jackson.annotation.JsonInclude; //导入方法依赖的package包/类
JsonSerializerParameters setInclude(JsonInclude.Include include);