org.nd4j.shade.jackson.annotation.JsonAutoDetect Java Examples

The following examples show how to use org.nd4j.shade.jackson.annotation.JsonAutoDetect. 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 vote down vote up
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: JsonMappers.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
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);
    ret.enable(SerializationFeature.INDENT_OUTPUT);
    SimpleModule atomicModule = new SimpleModule();
    atomicModule.addSerializer(AtomicDouble.class, new JsonSerializerAtomicDouble());
    atomicModule.addSerializer(AtomicBoolean.class, new JsonSerializerAtomicBoolean());
    atomicModule.addDeserializer(AtomicDouble.class, new JsonDeserializerAtomicDouble());
    atomicModule.addDeserializer(AtomicBoolean.class, new JsonDeserializerAtomicBoolean());
    ret.registerModule(atomicModule);
    //Serialize fields only, not using getters
    ret.setVisibilityChecker(ret.getSerializationConfig().getDefaultVisibilityChecker()
            .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
            .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withCreatorVisibility(JsonAutoDetect.Visibility.ANY)
    );
    return ret;
}
 
Example #3
Source File: BaseEvaluation.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
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);
    ret.enable(SerializationFeature.INDENT_OUTPUT);
    SimpleModule atomicModule = new SimpleModule();
    atomicModule.addSerializer(AtomicDouble.class,new JsonSerializerAtomicDouble());
    atomicModule.addSerializer(AtomicBoolean.class,new JsonSerializerAtomicBoolean());
    atomicModule.addDeserializer(AtomicDouble.class,new JsonDeserializerAtomicDouble());
    atomicModule.addDeserializer(AtomicBoolean.class,new JsonDeserializerAtomicBoolean());
    ret.registerModule(atomicModule);
    //Serialize fields only, not using getters
    ret.setVisibilityChecker(ret.getSerializationConfig().getDefaultVisibilityChecker()
            .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
            .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
    return ret;
}
 
Example #4
Source File: ObjectMappers.java    From konduit-serving with Apache License 2.0 5 votes vote down vote up
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 #5
Source File: JsonMappers.java    From DataVec with Apache License 2.0 5 votes vote down vote up
private static void 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);
}
 
Example #6
Source File: JsonMappers.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private static void 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);     //Need this otherwise JsonProperty annotations on constructors won't be seen
}
 
Example #7
Source File: ObjectMapperHolder.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: BaseTrainingMaster.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected static ObjectMapper getNewMapper(JsonFactory jsonFactory) {
    ObjectMapper om = new ObjectMapper(jsonFactory);
    om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    om.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
    om.enable(SerializationFeature.INDENT_OUTPUT);
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    om.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    return om;
}
 
Example #9
Source File: JsonMapper.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private static ObjectMapper getMapper(){
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    mapper.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY);

    return mapper;
}
 
Example #10
Source File: TestJson.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected static ObjectMapper getObjectMapper(JsonFactory factory) {
    ObjectMapper om = new ObjectMapper(factory);
    om.registerModule(new JodaModule());
    om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    om.enable(SerializationFeature.INDENT_OUTPUT);
    om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    om.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    om.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY);
    return om;
}