當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。