Refine search
public JsonMapper(Include include) { mapper = new ObjectMapper(); // 设置输出时包含属性的风格 if (include != null) { mapper.setSerializationInclusion(include); } // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性 mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
public JsonMapper(Include include) { mapper = new ObjectMapper(); // 设置输出时包含属性的风格 if (include != null) { mapper.setSerializationInclusion(include); } // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性 mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
private static ObjectMapper initWithoutIndentation() { return new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); } }
private ObjectMapper createJsonMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
private static ObjectMapper initWithIndentation() { return new ObjectMapper() .setSerializationInclusion(JsonInclude.Include.NON_NULL) .enable(SerializationFeature.INDENT_OUTPUT); }
static ObjectMapper getDefaultObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); return mapper; }
public JacksonJSONAdapter() { mapper = new ObjectMapper(); // 忽略多余的字段 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // 不输出为空的字段 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); }
public JacksonJSONAdapter() { mapper = new ObjectMapper(); // 忽略多余的字段 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // 不输出为空的字段 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); }
public static ObjectMapper create() { ObjectMapper mapper = new ObjectMapper(); // forward compatibility for the properties may go away in the future mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
public static ObjectMapper create() { ObjectMapper mapper = new ObjectMapper(); // forward compatibility for the properties may go away in the future mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, false); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
private static ObjectMapper objectMapper() { final ObjectMapper om = new ObjectMapper(); om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); om.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false); om.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false); om.setSerializationInclusion(Include.NON_NULL); om.setSerializationInclusion(Include.NON_EMPTY); return om; }
public static ObjectMapper createYaml() { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // forward compatibility for the properties may go away in the future mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
public JacksonProvider() { mapper = new ObjectMapper(); mapper.enable( SerializationFeature.INDENT_OUTPUT ); mapper.setSerializationInclusion( JsonInclude.Include.NON_NULL ); }
public JacksonContext() { this.mapper = new ObjectMapper() .enable(SerializationFeature.INDENT_OUTPUT) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .setSerializationInclusion(JsonInclude.Include.NON_NULL); }
@Override public ObjectMapper get() { final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false); objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); objectMapper.registerModule(new JsonProtoModule()); return objectMapper; } }
/** * Creates new {@link Jackson2HashMapper}. * * @param mapper must not be {@literal null}. * @param flatten */ public Jackson2HashMapper(ObjectMapper mapper, boolean flatten) { Assert.notNull(mapper, "Mapper must not be null!"); this.typingMapper = mapper; this.flatten = flatten; this.untypedMapper = new ObjectMapper(); this.untypedMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); this.untypedMapper.setSerializationInclusion(Include.NON_NULL); }
public static ObjectMapper init() { return new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .setSerializationInclusion(JsonInclude.Include.NON_EMPTY) .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE) .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); }
/** * Creates new {@link Jackson2HashMapper} with default {@link ObjectMapper}. * * @param flatten */ public Jackson2HashMapper(boolean flatten) { this(new ObjectMapper(), flatten); typingMapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY); typingMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); typingMapper.setSerializationInclusion(Include.NON_NULL); typingMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); }
/** * Pre-instantiate a Jackson ObjectMapper that will be handed off to all incoming Jersey * requests, and used to construct the ObjectWriters that will produce JSON responses. */ public JSONObjectMapperProvider() { // Create a module, i.e. a group of one or more Jackson extensions. // Our module includes a single class-serializer relationship. // Constructors are available for both unnamed, unversioned throwaway modules // and named, versioned reusable modules. mapper = new ObjectMapper() .registerModule(FeedScopedIdSerializer.makeModule()) .setSerializationInclusion(Include.NON_NULL); // skip null fields }