org.nd4j.shade.jackson.annotation.JsonInclude Java Examples
The following examples show how to use
org.nd4j.shade.jackson.annotation.JsonInclude.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectMappers.java From konduit-serving with Apache License 2.0 | 6 votes |
private static ObjectMapper configureMapper(ObjectMapper ret) { ret.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ret.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); ret.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, false); //Use order in which fields are defined in classes ret.enable(SerializationFeature.INDENT_OUTPUT); ret.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); ret.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); ret.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY); ret.setSerializationInclusion(JsonInclude.Include.NON_NULL); if (ret.getFactory() instanceof YAMLFactory) { ret.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); } ret.configure(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS, false); //Configure subtypes - via service loader from other modules List<JsonSubType> l = getAllSubtypes(); for(JsonSubType t : l){ NamedType nt = new NamedType(t.getSubtype(), t.getName()); ret.registerSubtypes(nt); } return ret; }
Example #2
Source File: ObjectMappers.java From konduit-serving with Apache License 2.0 | 5 votes |
private static ObjectMapper configureMapper(ObjectMapper ret) { ret.registerModule(new JodaModule()); ret.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ret.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); ret.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); ret.enable(SerializationFeature.INDENT_OUTPUT); ret.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); ret.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); ret.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY); ret.setSerializationInclusion(JsonInclude.Include.NON_NULL); if(ret.getFactory() instanceof YAMLFactory) { ret.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); } return ret; }
Example #3
Source File: ObjectMapperHolder.java From deeplearning4j with Apache License 2.0 | 5 votes |
private static ObjectMapper getMapper() { ObjectMapper om = new ObjectMapper(); //Serialize fields only, not using getters //Not all getters are supported - for example, UserEntity om.setVisibilityChecker(om.getSerializationConfig() .getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.ANY) .withGetterVisibility(JsonAutoDetect.Visibility.NONE) .withSetterVisibility(JsonAutoDetect.Visibility.NONE) .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); om.setSerializationInclusion(JsonInclude.Include.NON_NULL); return om; }