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


Java DeserializationFeature类代码示例

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


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

示例1: read

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public static SecurityAnalysisResult read(Path jsonFile) {
    Objects.requireNonNull(jsonFile);

    try (InputStream is = Files.newInputStream(jsonFile)) {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);

        SimpleModule module = new SimpleModule();
        module.addDeserializer(SecurityAnalysisResult.class, new SecurityAnalysisResultDeserializer());
        module.addDeserializer(NetworkMetadata.class, new NetworkMetadataDeserializer());
        module.addDeserializer(PostContingencyResult.class, new PostContingencyResultDeserializer());
        module.addDeserializer(LimitViolationsResult.class, new LimitViolationResultDeserializer());
        module.addDeserializer(LimitViolation.class, new LimitViolationDeserializer());
        module.addDeserializer(Contingency.class, new ContingencyDeserializer());
        module.addDeserializer(ContingencyElement.class, new ContingencyElementDeserializer());
        objectMapper.registerModule(module);

        return objectMapper.readValue(is, SecurityAnalysisResult.class);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:23,代码来源:SecurityAnalysisResultDeserializer.java

示例2: readInternal

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
protected <R extends Object> R readInternal(final DocumentDbPersistentEntity<?> entity, Class<R> type,
                                            final Document sourceDocument) {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    try {
        final DocumentDbPersistentProperty idProperty = entity.getIdProperty();
        final Object idValue = sourceDocument.getId();

        final JSONObject jsonObject = new JSONObject(sourceDocument.toJson());
        if (idProperty != null) {
            // Replace the key id to the actual id field name in domain
            jsonObject.remove("id");
            jsonObject.put(idProperty.getName(), idValue);
        }

        return objectMapper.readValue(jsonObject.toString(), type);
    } catch (IOException e) {
        throw  new IllegalStateException("Failed to read the source document " + sourceDocument.toJson()
                + "  to target type " + type, e);
    }
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:22,代码来源:MappingDocumentDbConverter.java

示例3: deserializeFromIndexFiles

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
protected List<PackageMetadata> deserializeFromIndexFiles(List<File> indexFiles) {
	List<PackageMetadata> packageMetadataList = new ArrayList<>();
	YAMLMapper yamlMapper = new YAMLMapper();
	yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	for (File indexFile : indexFiles) {
		try {
			MappingIterator<PackageMetadata> it = yamlMapper.readerFor(PackageMetadata.class).readValues(indexFile);
			while (it.hasNextValue()) {
				PackageMetadata packageMetadata = it.next();
				packageMetadataList.add(packageMetadata);
			}
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Can't parse Release manifest YAML", e);
		}
	}
	return packageMetadataList;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:19,代码来源:PackageMetadataService.java

示例4: CommentUserEventService

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
@Inject
public CommentUserEventService(Duniter4jClient client,
                               PluginSettings settings,
                               CryptoService cryptoService,
                               UserService userService,
                               UserEventService userEventService) {
    super("duniter.user.event.comment", client, settings, cryptoService);
    this.userService = userService;
    this.userEventService = userEventService;
    objectMapper = JacksonUtils.newObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    this.changeListenSources = ImmutableList.of(
            new ChangeSource(MarketIndexDao.INDEX, MarketCommentDao.TYPE),
            new ChangeSource(RegistryIndexDao.INDEX, RegistryCommentDao.TYPE));
    ChangeService.registerListener(this);

    this.trace = logger.isTraceEnabled();

    this.recordType = RecordDao.TYPE;
}
 
开发者ID:duniter-gchange,项目名称:gchange-pod,代码行数:21,代码来源:CommentUserEventService.java

示例5: getAppStatusList

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
@JsonIgnore
public List<AppStatus> getAppStatusList() {
	try {
		ObjectMapper mapper = new ObjectMapper();
		mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
		SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
		resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
		module.setAbstractTypes(resolver);
		mapper.registerModule(module);
		TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
		};
		if (this.platformStatus != null) {
			return mapper.readValue(this.platformStatus, typeRef);
		}
		return new ArrayList<AppStatus>();
	}
	catch (Exception e) {
		throw new IllegalArgumentException("Could not parse Skipper Platfrom Status JSON:" + platformStatus, e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:23,代码来源:Status.java

示例6: provideObjectMapper

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public ObjectMapper provideObjectMapper() {
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
  objectMapper.setSerializationInclusion(Include.NON_NULL);
  objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
  objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

  objectMapper.setDateFormat(provideDateFormat());

  return objectMapper;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:14,代码来源:RetrofitModule.java

示例7: doInBackground

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
@Override
protected String doInBackground(Void... params) {
    ObjectMapper objectMapper = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES).disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
    String comentarioJSON="";
    //Construyo el JSON
    try {
        comentarioJSON = objectMapper.writeValueAsString(comentario);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    String resultado = null;

    //Cojo el resultado en un String
    resultado = ConsultasBBDD.hacerConsulta(ConsultasBBDD.insertaComentario, comentarioJSON, "POST");


    return resultado;
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:19,代码来源:FragmentComentariosProyecto.java

示例8: getRestTemplate

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
protected RestTemplate getRestTemplate() {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.registerModule(new Jackson2HalModule());

	MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
	converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
	converter.setObjectMapper(mapper);

	return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
 
开发者ID:ewolff,项目名称:microservice-cloudfoundry,代码行数:12,代码来源:CatalogClient.java

示例9: DefaultLicenseManager

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public DefaultLicenseManager(String publicKey) {
    this.currentVersion = DefaultLicenseManager.LicenseVersion.PRODUCT_SIGNATURE_VERSION;
    this.registeredProducts = new LinkedList();
    this.loadedLicenses = new HashMap();
    this.productToActiveLicenseMap = new HashMap();
    this.productToStarterLicenseMap = new HashMap();
    this.licenseManagerListeners = new LinkedList();

    try {
        X509EncodedKeySpec e = new X509EncodedKeySpec(Base.decode(publicKey == null?"H4sIAAAAAAAAAAEmAdn+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA58/mQ8VjKWDj9ai3mTzFX0b2S0VbV7LIQFv97U8ePdFoLu/cAcTvw7jsvQAT/3RHS7kzXXOk4OGDb7rmL85Dw6nfDs1jFA1auvrICW2vvOdpLrOOijJX5S5EJWHxKoBXSOfxU/fKFa93iuSVKJdqXJeah2Lgs/wq54BBcp4SrxogwWiuqFImqDo7BZKAZgLSm/v2IlICxKGM9QgAoYYLL/bongBpp6SxTy1gm/YD108jJxEk5wuFefDPDMlP0kioSsmGonU6o++pqYLuLkbFdNOdbmtoTphzP5vNaLaTQBmw9vuFHqh80BmIEQi6pK/Wz2RjOU6CYDpn9wv1Lgo2JQIDAQABbOI6ryYBAAA=":publicKey));
        KeyFactory kf = KeyFactory.getInstance("RSA");
        this.publicKey = kf.generatePublic(e);
    } catch (InvalidKeySpecException | IOException | NoSuchAlgorithmException var4) {
        throw new IllegalStateException("PublicKey could not be initialized.", var4);
    }

    this.jsonObjectMapper = new ObjectMapper();
    this.licenseAnnotationValidator = new LicenseAnnotationValidator(this);
    this.jsonObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:DefaultLicenseManager.java

示例10: setUp

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mapper = Jackson2ObjectMapperBuilder.json()
            .featuresToDisable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
            .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .build();
    mapper.findAndRegisterModules();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:9,代码来源:DefaultAuthenticationTests.java

示例11: JsonMapper

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public JsonMapper() {
    // calls the default constructor
    super();

    // configures ISO8601 formatter for date without time zone
    // the used format is 'yyyy-MM-dd'
    super.setDateFormat(new SimpleDateFormat(FMT_ISO_LOCAL_DATE));

    // enforces to skip null and empty values in the serialized JSON output
    super.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    // enforces to skip null references in the serialized output of Map
    super.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);

    // enables serialization failures, when mapper encounters unknown properties names
    super.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    // configures the format to prevent writing of the serialized output for java.util.Date
    // instances as timestamps. any date should be written in ISO format
    super.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:22,代码来源:JsonMapper.java

示例12: configureerMapper

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
private void configureerMapper() {
    // Configuratie
    this.disable(MapperFeature.AUTO_DETECT_CREATORS);
    this.disable(MapperFeature.AUTO_DETECT_FIELDS);
    this.disable(MapperFeature.AUTO_DETECT_GETTERS);
    this.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
    this.disable(MapperFeature.AUTO_DETECT_SETTERS);

    // Default velden niet als JSON exposen (expliciet annoteren!)
    setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE);
    this.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
    this.enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);

    // serialization
    this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    this.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);

    // deserialization
    this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:BrpJsonObjectMapper.java

示例13: loadGenesisJson

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public static GenesisJson loadGenesisJson(InputStream genesisJsonIS) throws RuntimeException {
    String json = null;
    try {
        json = new String(ByteStreams.toByteArray(genesisJsonIS));

        ObjectMapper mapper = new ObjectMapper()
                .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);

        GenesisJson genesisJson  = mapper.readValue(json, GenesisJson.class);
        return genesisJson;
    } catch (Exception e) {

        Utils.showErrorAndExit("Problem parsing genesis: "+ e.getMessage(), json);

        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:19,代码来源:GenesisLoader.java

示例14: getAccounts

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
public List<Account> getAccounts() {
    final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    final ObjectMapper mapper = new ObjectMapper()
            .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    List<Account> accounts = null;
    try {
        accounts = mapper.readValue(rulesFile, 
                new TypeReference<List<Account>>() {});
        if (accounts != null) {
            accounts.forEach((account) -> {
                final Set<ConstraintViolation<Account>> accountViolations = validator.validate(account);
                if (accountViolations.size() > 0) {
                    throw new AccountValidationException(accountViolations);
                }
                account.getRules().sort((o1, o2) -> o1.getType().compareTo(o2.getType()));
            });
        }
    } catch (IOException ex) {
        Logger.getLogger(AccountService.class.getName()).log(Level.SEVERE, null, ex);
    }

    return accounts;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:24,代码来源:AccountService.java

示例15: doInBackground

import com.fasterxml.jackson.databind.DeserializationFeature; //导入依赖的package包/类
@Override
protected EpubPublication doInBackground(String... urls) {
    String strUrl = urls[0];

    try {
        URL url = new URL(strUrl);
        URLConnection urlConnection = url.openConnection();
        InputStream inputStream = urlConnection.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder stringBuilder = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            stringBuilder.append(line);
        }

        Log.d("TestActivity", "EpubPublication => " + stringBuilder.toString());

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

        return objectMapper.readValue(stringBuilder.toString(), EpubPublication.class);
    } catch (IOException e) {
        Log.e(TAG, "SpineListTask error " + e);
    }
    return null;
}
 
开发者ID:codetoart,项目名称:r2-streamer-java,代码行数:27,代码来源:TestActivity.java


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