本文整理了Java中com.fasterxml.jackson.databind.ObjectMapper.setDefaultPropertyInclusion()
方法的一些代码示例,展示了ObjectMapper.setDefaultPropertyInclusion()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper.setDefaultPropertyInclusion()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.ObjectMapper
类名称:ObjectMapper
方法名:setDefaultPropertyInclusion
[英]Short-cut for:
setDefaultPropertyInclusion(JsonInclude.Value.construct(incl, incl));
[中]
代码示例来源:origin: redisson/redisson
/**
* @since 2.7
* @deprecated Since 2.9 use {@link #setDefaultPropertyInclusion}
*/
@Deprecated
public ObjectMapper setPropertyInclusion(JsonInclude.Value incl) {
return setDefaultPropertyInclusion(incl);
}
代码示例来源:origin: apache/nifi
public ObjectMapperResolver() throws Exception {
mapper = new ObjectMapper();
mapper.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS));
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(mapper.getTypeFactory()));
}
代码示例来源:origin: apache/nifi
private static JacksonJaxbJsonProvider jacksonJaxbJsonProvider() {
JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider();
ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL));
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(mapper.getTypeFactory()));
// Ignore unknown properties so that deployed client remain compatible with future versions of NiFi that add new fields
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
jacksonJaxbJsonProvider.setMapper(mapper);
return jacksonJaxbJsonProvider;
}
}
代码示例来源:origin: apache/nifi
objectMapper.setDefaultPropertyInclusion(Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.ALWAYS));
System.out.println("s2s is a command line tool that can either read a list of DataPackets from stdin to send over site-to-site or write the received DataPackets to stdout");
System.out.println();
代码示例来源:origin: spring-projects/spring-security
@Test
public void serializingThenDeserializingWithConfiguredObjectMapperShouldWork() throws IOException {
// given
this.mapper.setDefaultPropertyInclusion(construct(ALWAYS, NON_NULL)).setSerializationInclusion(NON_ABSENT);
UsernamePasswordAuthenticationToken original = new UsernamePasswordAuthenticationToken("Frodo", null);
// when
String serialized = this.mapper.writeValueAsString(original);
UsernamePasswordAuthenticationToken deserialized =
this.mapper.readValue(serialized, UsernamePasswordAuthenticationToken.class);
// then
assertThat(deserialized).isEqualTo(original);
}
代码示例来源:origin: apache/nifi
public OkHttpReplicationClient(final NiFiProperties properties) {
jsonCodec.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS));
jsonCodec.setAnnotationIntrospector(new JaxbAnnotationIntrospector(jsonCodec.getTypeFactory()));
jsonSerializer = new JsonEntitySerializer(jsonCodec);
xmlSerializer = new XmlEntitySerializer();
okHttpClient = createOkHttpClient(properties);
}
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
/**
* @since 2.7
* @deprecated Since 2.9 use {@link #setDefaultPropertyInclusion}
*/
@Deprecated
public ObjectMapper setPropertyInclusion(JsonInclude.Value incl) {
return setDefaultPropertyInclusion(incl);
}
代码示例来源:origin: graphql-java-kickstart/graphql-java-servlet
public ObjectMapper getJacksonMapper() {
ObjectMapper result = mapper;
if (result == null) { // First check (no locking)
synchronized(this) {
result = mapper;
if (result == null) { // Second check (with locking)
mapper = result = objectMapperProvider.provide().copy();
mapper.setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS);
}
}
}
return result;
}
代码示例来源:origin: batfish/batfish
/** Configures all the default options for a Batfish {@link ObjectMapper}. */
private static ObjectMapper baseMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
mapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
// Next two lines make Instant class serialize as an RFC-3339 timestamp
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// This line makes Java 8's Optional type serialize
mapper.registerModule(new Jdk8Module());
// See https://groups.google.com/forum/#!topic/jackson-user/WfZzlt5C2Ww
// This fixes issues in which non-empty maps with keys with empty values would get omitted
// entirely. See also https://github.com/batfish/batfish/issues/256
mapper.setDefaultPropertyInclusion(
JsonInclude.Value.construct(Include.NON_EMPTY, Include.ALWAYS));
// This line makes Guava collections work with jackson
mapper.registerModule(new GuavaModule());
return mapper;
}
}
代码示例来源:origin: org.apache.nifi/nifi-toolkit-s2s
objectMapper.setDefaultPropertyInclusion(Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.ALWAYS));
System.out.println("s2s is a command line tool that can either read a list of DataPackets from stdin to send over site-to-site or write the received DataPackets to stdout");
System.out.println();
代码示例来源:origin: io.airlift/json
objectMapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_ABSENT, JsonInclude.Include.ALWAYS));
代码示例来源:origin: airlift/airlift
objectMapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_ABSENT, JsonInclude.Include.ALWAYS));
代码示例来源:origin: com.proofpoint.platform/json
objectMapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_ABSENT, JsonInclude.Include.ALWAYS));
代码示例来源:origin: org.apache.geronimo/geronimo-openapi-impl
return mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
代码示例来源:origin: gentics/mesh
defaultMapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(Include.NON_NULL, Include.ALWAYS));
defaultMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
代码示例来源:origin: batfish/batfish
@Test
public void testMapFieldWithEmptyValue() throws JsonProcessingException {
Foo foo = new Foo();
foo._map.put("key", new String[0]);
ObjectMapper mapper =
new ObjectMapper()
.setDefaultPropertyInclusion(
JsonInclude.Value.construct(Include.NON_EMPTY, Include.ALWAYS));
assertThat(mapper.writeValueAsString(foo), allOf(containsString("map"), containsString("key")));
}
内容来源于网络,如有侵权,请联系作者删除!