本文整理汇总了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());
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}