当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.setVisibilityChecker方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.setVisibilityChecker方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.setVisibilityChecker方法的具体用法?Java ObjectMapper.setVisibilityChecker怎么用?Java ObjectMapper.setVisibilityChecker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.setVisibilityChecker方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Before public void setUp() {
  SimpleModule module = new SimpleModule();
  module.addSerializer(AnInterface.class, new AnInterfaceSerializer());
  module.addDeserializer(AnInterface.class, new AnInterfaceDeserializer());
  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(module);
  mapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false);
  mapper.configure(MapperFeature.AUTO_DETECT_SETTERS, false);
  mapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false);
  mapper.setVisibilityChecker(mapper.getSerializationConfig()
      .getDefaultVisibilityChecker()
      .withFieldVisibility(JsonAutoDetect.Visibility.ANY));

  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(JacksonConverterFactory.create(mapper))
      .build();
  service = retrofit.create(Service.class);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:JacksonConverterFactoryTest.java

示例2: serializeFieldsOnly

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static String serializeFieldsOnly(Object value, boolean pretty) {
    try {
        ObjectMapper mapper = createMapper(pretty);
        mapper.setVisibilityChecker(fieldsOnlyVisibilityChecker(mapper));

        return mapper.writeValueAsString(value);
    } catch (Exception e) {
        LOGGER.error("JSON serialization error: ", e);
        return "{}";
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:12,代码来源:Serializers.java

示例3: init

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected void init(ObjectMapper objectMapper) {
    objectMapper.registerModule(new DefenceModule());
    
    objectMapper.setSerializationInclusion(Include.NON_NULL);
    objectMapper.setVisibilityChecker(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
            .withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
    objectMapper.addMixIn(Throwable.class, ThrowableMixIn.class);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:JsonJacksonCodec.java

示例4: exportJson

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void exportJson(Map<Method, Set<Invocation>> data) {
	try {
		ObjectMapper mapper = new ObjectMapper();
		mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
		String formatted = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
		LOGGER.debug("Dereferences: {}", formatted);
	} catch (JsonProcessingException exception) {
		LOGGER.warn("Export of dereferences failed", exception);
	}
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:11,代码来源:Main.java

示例5: getPage

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static MobileScreen getPage(File file) throws Throwable {
    MobileScreen mobileScreen;
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    try {
        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        mapper.setVisibilityChecker(VisibilityChecker.Std.defaultInstance().withFieldVisibility(JsonAutoDetect.Visibility.ANY));
        mobileScreen = mapper.readValue(file, MobileScreen.class);

    } catch (Exception e) {
        e.printStackTrace();
        throw e.getCause();
    }
    return mobileScreen;
}
 
开发者ID:AshokKumarMelarkot,项目名称:msa-cucumber-appium,代码行数:15,代码来源:MobileApp.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.setVisibilityChecker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。