本文整理匯總了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;
}
}