本文整理匯總了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);