本文整理汇总了Java中com.fasterxml.jackson.core.ObjectCodec.readValue方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectCodec.readValue方法的具体用法?Java ObjectCodec.readValue怎么用?Java ObjectCodec.readValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.ObjectCodec
的用法示例。
在下文中一共展示了ObjectCodec.readValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public ChatAlyticsEvent deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
JsonParser eventTimeParser = node.get("event_time").traverse();
DateTime eventTime = oc.readValue(eventTimeParser, DateTime.class);
String type = node.get("type").asText();
Class<?> clazz;
String classStr = node.get("clazz").asText();
try {
clazz = Class.forName(classStr);
} catch (ClassNotFoundException e) {
throw new IOException("Can't load class for " + classStr, e);
}
JsonParser eventParser = node.get("event").traverse();
Object event = oc.readValue(eventParser, clazz);
return new ChatAlyticsEvent(eventTime, type, event);
}
示例2: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public List<String> deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
List<String> result;
ObjectCodec codec = p.getCodec();
if (p.getCurrentToken().equals(JsonToken.START_ARRAY)) {
result = codec.readValue(p, new TypeReference<List<String>>() { });
} else {
LinkedHashMap<Integer, String> map = codec.readValue(p,
new TypeReference<LinkedHashMap<Integer, String>>() { });
result = new ArrayList<String>(map.values());
}
return result;
}
示例3: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public LinkedHashMap<String, String> deserialize(JsonParser jp,
DeserializationContext ctxt) throws IOException,
JsonProcessingException {
LinkedHashMap<String, String> result = null;
// Is the alias broken, i.e., it starts with '['
if (jp.getCurrentToken().equals(JsonToken.START_ARRAY)) {
result = new LinkedHashMap<String, String>();
jp.nextToken();
if (!jp.getCurrentToken().equals(JsonToken.END_ARRAY)) {
logger.warn("Token " + JsonToken.END_ARRAY + " expected");
}
} else {
ObjectCodec mapper = jp.getCodec();
result = mapper.readValue(jp,
new TypeReference<LinkedHashMap<String, String>>() { });
}
return result;
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:23,代码来源:OldLabelsDescriptionsDeserializer.java
示例4: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public LinkedHashMap<String, OldJacksonSiteLink> deserialize(JsonParser jp,
DeserializationContext ctxt) throws IOException,
JsonProcessingException {
LinkedHashMap<String, OldJacksonSiteLink> result = null;
// Is the alias broken, i.e., it starts with '['
if (jp.getCurrentToken().equals(JsonToken.START_ARRAY)) {
result = new LinkedHashMap<String, OldJacksonSiteLink>();
jp.nextToken();
if (!jp.getCurrentToken().equals(JsonToken.END_ARRAY)) {
logger.warn("Token " + JsonToken.END_ARRAY + " expected");
}
} else {
ObjectCodec mapper = jp.getCodec();
result = mapper.readValue(jp,
new TypeReference<LinkedHashMap<String, OldJacksonSiteLink>>() { });
}
return result;
}
示例5: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public LinkedHashMap<String, List<String>> deserialize(
JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException {
LinkedHashMap<String, List<String>> result =
new LinkedHashMap<String, List<String>>();
// Is the alias broken, i.e., it starts with '['
if (jp.getCurrentToken().equals(JsonToken.START_ARRAY)) {
jp.nextToken();
if (!jp.getCurrentToken().equals(JsonToken.END_ARRAY)) {
logger.warn("Token " + JsonToken.END_ARRAY + " expected");
}
} else {
ObjectCodec mapper = jp.getCodec();
result = mapper.readValue(jp,
new TypeReference<LinkedHashMap<String, OldAliasList>>() { });
}
return result;
}
示例6: deserializeObject
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
protected GitterMessage deserializeObject(JsonParser jsonParser, DeserializationContext deserializationContext,
ObjectCodec objectCodec, JsonNode jsonNode) throws IOException {
String id = nullSafeValue(jsonNode.get("id"), String.class);
String text = nullSafeValue(jsonNode.get("text"), String.class);
String html = nullSafeValue(jsonNode.get("html"), String.class);
JsonNode userNode = jsonNode.get("fromUser");
GitterUser user = objectCodec.readValue(userNode.traverse(objectCodec), GitterUser.class);
String sent = nullSafeValue(jsonNode.get("sent"), String.class);
return new GitterMessage(id, text, html, user, Instant.parse(sent));
}
示例7: makeDeserialiser
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
private BiFunction<JsonNode, Type, Object> makeDeserialiser(ObjectMapper mapper) {
final TypeFactory typeFactory = mapper.getTypeFactory();
return (node, type) -> {
JavaType javaType = typeFactory.constructType(type);
try {
final JsonParser jsonParser = mapper.treeAsTokens(node);
final ObjectCodec codec = jsonParser.getCodec();
return codec.readValue(jsonParser, javaType);
} catch (IOException e) {
throw new RuntimeException(e);
}
};
}
示例8: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public Circuit deserialize(JsonParser parser, DeserializationContext context)
throws IOException {
Circuit circuit = new Circuit();
ObjectCodec codec = parser.getCodec();
GeoPoint[] coordinates = codec.readValue(parser, GeoPoint[].class);
circuit.setCoordinates(Arrays.asList(coordinates));
return circuit;
}
示例9: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public List<ColumnMetadata> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException {
ObjectCodec oc = jsonParser.getCodec();
final List<ColumnMetadata> columnMetadata = oc.readValue(jsonParser, new TypeReference<List<ColumnMetadata>>() {
});
deserializationContext.setAttribute(ColumnContextDeserializer.class.getName(), columnMetadata);
return columnMetadata;
}
示例10: deserialize
import com.fasterxml.jackson.core.ObjectCodec; //导入方法依赖的package包/类
@Override
public Intent deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectCodec objectCodec = jp.getCodec();
Map<String, Object> map = objectCodec.readValue(jp, new TypeReference<Map<String, Object>>() {
});
String json = JsonUtils.serialize(map);
if (!map.containsKey("type") || map.get("type") == null)
return null;
IntentType type = null;
try {
type = IntentType.valueOf((String) map.get("type"));
} catch (IllegalArgumentException e) {
logger.warn("Invalid intent type: " + e.getMessage());
return null;
}
switch (type) {
case custom:
return JsonUtils.deserialize(json, CustomIntent.class);
case noop:
return JsonUtils.deserialize(json, NoopIntent.class);
case url:
return JsonUtils.deserialize(json, UrlIntent.class);
default:
logger.warn("Invalid intent type: null");
return null;
}
}