本文整理了Java中org.codehaus.jackson.JsonNode.traverse()
方法的一些代码示例,展示了JsonNode.traverse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.traverse()
方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:traverse
[英]Method for constructing a JsonParser instance for iterating over contents of the tree that this node is root of. Functionally equivalent to first serializing tree using ObjectCodec and then re-parsing but more efficient.
[中]方法,该方法用于构造一个JsonParser实例,用于迭代此节点所在树的内容。功能上相当于首先使用ObjectCodec序列化树,然后重新解析,但效率更高。
代码示例来源:origin: Orange-OpenSource/spring-social-weibo
@Override
public SortedSet<Trends> deserialize(JsonParser jp,
DeserializationContext ctxt) throws IOException,
JsonProcessingException {
SimpleDateFormat dateFormat = new SimpleDateFormat();
TreeSet<Trends> result = new TreeSet<Trends>(comparator);
for (Iterator<Entry<String, JsonNode>> iterator = jp.readValueAsTree()
.getFields(); iterator.hasNext();) {
Entry<String, JsonNode> next = iterator.next();
Trends trends = new Trends();
try {
dateFormat
.applyPattern(retrieveDateFormatPattern(next.getKey()));
trends.setDate(dateFormat.parse(next.getKey()));
JsonNode trendsNode = next.getValue();
for (Iterator<JsonNode> iterator2 = trendsNode.getElements(); iterator2
.hasNext();) {
JsonParser nodeParser = iterator2.next().traverse();
nodeParser.setCodec(jp.getCodec());
Trend readValueAs = nodeParser.readValueAs(Trend.class);
trends.getTrends().add(readValueAs);
}
result.add(trends);
} catch (ParseException e) {
logger.warn("Unable to parse date", e);
}
}
return result;
}
代码示例来源:origin: org.apache.eagle/eagle-entity-base
Map.Entry<String,JsonNode> field = fields.next();
if (META_FIELD.equals(field.getKey()) && field.getValue() != null)
entity.setMeta(objectCodec.readValue(field.getValue().traverse(), Map.class));
else if(SUCCESS_FIELD.equals(field.getKey()) && field.getValue() != null){
entity.setSuccess(field.getValue().getValueAsBoolean(false));
collectionType = TypeFactory.defaultInstance().constructCollectionType(LinkedList.class, Map.class);
List obj = objectCodec.readValue(objNode.traverse(), collectionType);
entity.setObj(obj);
内容来源于网络,如有侵权,请联系作者删除!