本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS属性的典型用法代码示例。如果您正苦于以下问题:Java Include.ALWAYS属性的具体用法?Java Include.ALWAYS怎么用?Java Include.ALWAYS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.fasterxml.jackson.annotation.JsonInclude.Include
的用法示例。
在下文中一共展示了Include.ALWAYS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleMerge
public void testSimpleMerge()
{
JsonInclude.Value empty = JsonInclude.Value.empty();
assertEquals(Include.USE_DEFAULTS, empty.getValueInclusion());
assertEquals(Include.USE_DEFAULTS, empty.getContentInclusion());
JsonInclude.Value v2 = empty.withValueInclusion(Include.NON_ABSENT);
assertEquals(Include.NON_ABSENT, v2.getValueInclusion());
assertEquals(Include.USE_DEFAULTS, v2.getContentInclusion());
JsonInclude.Value v3 = new JsonInclude.Value(Include.NON_EMPTY, Include.ALWAYS,
null, null);
assertEquals(Include.NON_EMPTY, v3.getValueInclusion());
assertEquals(Include.ALWAYS, v3.getContentInclusion());
// Ok; but then overrides, which should skip 'USE_DEFAULT' overrides
JsonInclude.Value merged = v3.withOverrides(empty);
// no overrides with "empty":
assertEquals(v3.getValueInclusion(), merged.getValueInclusion());
assertEquals(v3.getContentInclusion(), merged.getContentInclusion());
// but other values ought to be overridden (value, yes, content, no because it's default)
merged = JsonInclude.Value.merge(v3, v2);
assertEquals(v2.getValueInclusion(), merged.getValueInclusion());
assertEquals(v3.getContentInclusion(), merged.getContentInclusion());
merged = JsonInclude.Value.mergeAll(empty, v3);
assertEquals(v3.getValueInclusion(), merged.getValueInclusion());
assertEquals(v3.getContentInclusion(), merged.getContentInclusion());
}
示例2: JsonMapper
public JsonMapper() {
this(Include.ALWAYS);
}