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


Java ObjectMapper.readerFor方法代码示例

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


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

示例1: findAll

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public List<KeyValueConfigEntity> findAll(@Nonnull KeyValueConfigName configName) throws Exception {
  Objects.requireNonNull(configName);

  String collectionName = configName.getQualifiedName();
  MongoCollection<RawBsonDocument> collection =
      connector.getDatabase().getCollection(collectionName, RawBsonDocument.class);

  MongoCursor<RawBsonDocument> it = collection.find().iterator();
  if (!it.hasNext()) {
    return Collections.emptyList();
  }

  RawBsonDocument document = it.next();
  ByteArrayInputStream bin = new ByteArrayInputStream(document.getByteBuffer().array());
  ObjectMapper objectMapper = MongoConfigObjectMapper.getInstance();
  ObjectReader objectReader = objectMapper.readerFor(MongoConfigEntity.class);
  List<KeyValueConfigEntity> result = ((MongoConfigEntity) objectReader.readValue(bin)).getConfig();

  // set groupName on returned config key-value pairs
  return result.stream().map(input -> input.setConfigName(configName)).collect(Collectors.toList());
}
 
开发者ID:scalecube,项目名称:config,代码行数:23,代码来源:MongoConfigRepository.java

示例2: decode

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public Map<String, Object> decode(String base64EncodedKey, String content) {
    try {
        byte[] decodedKey = Base64.getDecoder().decode(base64EncodedKey);
        SecretKey key = new SecretKeySpec(decodedKey, 0, decodedKey.length, "AES");
        JWEObject jwe = JWEObject.parse(content);
        jwe.decrypt(new AESDecrypter(key));

        ObjectMapper objectMapper = new ObjectMapper();
        ObjectReader reader = objectMapper.readerFor(Map.class);
        return reader.with(DeserializationFeature.USE_LONG_FOR_INTS)
                .readValue(jwe.getPayload().toString());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:17,代码来源:JweTokenSerializer.java

示例3: JsonPatchOperationTest

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected JsonPatchOperationTest(final String prefix) throws IOException {
    final String resource = "/jsonpatch/" + prefix + ".json";
    URL url = getClass().getResource(resource);
    ObjectMapper objectMapper = new ObjectMapper();
    final JsonNode node = objectMapper.readTree(url);
    errors = node.get("errors");
    ops = node.get("ops");
    reader = objectMapper.readerFor(JsonPatchOperation.class);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:10,代码来源:JsonPatchOperationTest.java

示例4: RawResourceFieldAccessor

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public RawResourceFieldAccessor(String fieldName, ResourceFieldType fieldType, Class type) {
	this.fieldName = fieldName;
	this.fieldType = fieldType;
	this.type = type;

	ObjectMapper mapper = new ObjectMapper();
	reader = mapper.readerFor(type);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:9,代码来源:RawResourceFieldAccessor.java

示例5: parseRepo

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private Repo parseRepo(ObjectMapper mapper, JsonParser parser) throws IOException {
    parser.nextToken();
    parser.nextToken();
    ObjectReader repoReader = mapper.readerFor(Repo.class);
    return repoReader.readValue(parser, Repo.class);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:7,代码来源:IndexV1UpdaterTest.java

示例6: JacksonSerializer

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public JacksonSerializer(final ObjectMapper mapper, final Class<T> klazz) {
  this.reader = mapper.readerFor(klazz);
  this.writer = mapper.writer();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:JacksonSerializer.java


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