本文整理了Java中com.fasterxml.jackson.databind.JsonNode.iterator()
方法的一些代码示例,展示了JsonNode.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.iterator()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:iterator
[英]Same as calling #elements; implemented so that convenience "for-each" loop can be used for looping over elements of JSON Array constructs.
[中]与调用#元素相同;实现后,方便的“for each”循环可用于在JSON数组构造的元素上循环。
代码示例来源:origin: mrniko/netty-socketio
@Override
public AckArgs deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException {
List<Object> args = new ArrayList<Object>();
AckArgs result = new AckArgs(args);
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
JsonNode root = mapper.readTree(jp);
AckCallback<?> callback = currentAckClass.get();
Iterator<JsonNode> iter = root.iterator();
int i = 0;
while (iter.hasNext()) {
Object val;
Class<?> clazz = callback.getResultClass();
if (callback instanceof MultiTypeAckCallback) {
MultiTypeAckCallback multiTypeAckCallback = (MultiTypeAckCallback) callback;
clazz = multiTypeAckCallback.getResultClasses()[i];
}
JsonNode arg = iter.next();
if (arg.isTextual() || arg.isBoolean()) {
clazz = Object.class;
}
val = mapper.treeToValue(arg, clazz);
args.add(val);
i++;
}
return result;
}
代码示例来源:origin: aws/aws-sdk-java
if (element != null) {
if (element.isArray()) {
Iterator<JsonNode> inner = element.iterator();
while (inner.hasNext()) {
JsonNode innerElement = inner.next();
代码示例来源:origin: briandilley/jsonrpc4j
" \"result\": \"test.ru\"}\n" +
"}";
Iterator<JsonNode> paramsIterator = mapper.readTree(requestGood).at("/params").iterator();
List<JsonNode> paramsNodes = new ArrayList<>();
while (paramsIterator.hasNext()) {
代码示例来源:origin: stackoverflow.com
JsonNode data = node.path("data");
if (!data.isMissingNode()) { // checks if data exists
if (data.iterator().hasNext()) { // checks if data is not empty
// get first child ("unwrap")
JsonNode firstNodeInsideData = data.iterator().next();
}
}
代码示例来源:origin: io.macgyver/macgyver-core
public static List<JsonNode> arrayToList(JsonNode n) {
if (n.isArray()) {
return Lists.newArrayList(n.iterator());
} else {
return Lists.newArrayList();
}
}
代码示例来源:origin: org.walkmod/walkmod-core
public String[] getFileSet(JsonNode parent) {
String[] includes = new String[parent.size()];
Iterator<JsonNode> includesIt = parent.iterator();
int j = 0;
while (includesIt.hasNext()) {
JsonNode item = includesIt.next();
includes[j] = item.asText();
j++;
}
return includes;
}
代码示例来源:origin: com.atlassian.oai/swagger-request-validator-core
private static Iterator<JsonNode> properties(final JsonNode n) {
if (n.has(PROPERTIES_FIELD)) {
return n.get(PROPERTIES_FIELD).iterator();
}
return Collections.<JsonNode>emptyList().iterator();
}
代码示例来源:origin: walkmod/walkmod-core
public String[] getFileSet(JsonNode parent) {
String[] includes = new String[parent.size()];
Iterator<JsonNode> includesIt = parent.iterator();
int j = 0;
while (includesIt.hasNext()) {
JsonNode item = includesIt.next();
includes[j] = item.asText();
j++;
}
return includes;
}
代码示例来源:origin: bitrich-info/xchange-stream
static Stream<BitfinexWebSocketAuthBalance> adaptBalances(JsonNode balances) {
Iterable<JsonNode> iterator = () -> balances.iterator();
return stream(iterator.spliterator(), false)
.filter(o -> o.size() >= 5)
.map(BitfinexStreamingAdapters::createBalanceObject)
.peek(o -> LOG.debug("Balance: {}", o));
}
代码示例来源:origin: bitrich-info/xchange-stream
static Stream<BitfinexWebSocketAuthOrder> adaptOrders(JsonNode orders) {
Iterable<JsonNode> iterator = () -> orders.iterator();
return stream(iterator.spliterator(), false)
.filter(o -> o.size() >= 32)
.map(BitfinexStreamingAdapters::createOrderObject)
.peek(o -> LOG.debug("New order: {}", o));
}
代码示例来源:origin: allegro/hermes
private <T> List<Matcher> parseObjectArray(JsonNode node) {
return stream(node.iterator())
.map(this::parseCompoundObject)
.collect(Collectors.toList());
}
代码示例来源:origin: org.agorava/agorava-facebook-cdi
private <T> List<T> deserializeList(JsonNode jsonNode, String postType, Class<T> type) {
JsonNode dataNode = jsonNode.get("data");
List<T> posts = new ArrayList<T>();
for (Iterator<JsonNode> iterator = dataNode.iterator(); iterator.hasNext(); ) {
posts.add(deserializePost(postType, type, (ObjectNode) iterator.next()));
}
return posts;
}
代码示例来源:origin: org.wololo/jts2geojson
private static FeatureCollection readFeatureCollection(JsonNode node)
throws JsonParseException, JsonMappingException, IOException, ClassNotFoundException {
Iterator<JsonNode> it = node.get("features").iterator();
List<Feature> features = new ArrayList<Feature>();
while (it.hasNext()) {
JsonNode jFeature = it.next();
features.add(readFeature(jFeature));
}
return new FeatureCollection(features.toArray(new Feature[features.size()]));
}
代码示例来源:origin: io.macgyver/macgyver-core
public List<MenuItem> getItems() {
List<MenuItem> tmp = Lists.newArrayList();
for (JsonNode n : Lists.newArrayList(itemNode.path("items").iterator())) {
MenuItem m = new MenuItem((ObjectNode) n);
tmp.add(m);
}
return tmp;
}
代码示例来源:origin: io.macgyver/macgyver-core
public void migrateRolesForUser(String username) {
JsonNode n = neo4j
.execCypher("match (u:User {username: {username}}) return u",
"username", username).toBlocking().first();
for (JsonNode s : Lists.newArrayList(n.path("roles").iterator())) {
String roleName = s.asText();
logger.info("adding role={} to user={}", roleName, username);
addRoleToUser(username, roleName);
}
}
代码示例来源:origin: com.hotels.road/road-offramp-service
private JsonNode transform(JsonNode jsonNode, String pointer) {
if (pointer.contains(COLLECTION_SYMBOL)) {
List<String> paths = collectionSplitter.splitToList(pointer);
jsonNode.at(paths.get(0)).iterator().forEachRemaining(v -> transform(v, paths.get(1)));
} else {
transformLeafPath(jsonNode, pointer);
}
return jsonNode;
}
代码示例来源:origin: io.syndesis/connector-catalog
private String extractLabels(JsonNode tree) {
Iterator<JsonNode> it = tree.withArray("labels").iterator();
CollectionStringBuffer csb = new CollectionStringBuffer(",");
while (it.hasNext()) {
String text = it.next().textValue();
csb.append(text);
}
return csb.toString();
}
代码示例来源:origin: HotelsDotCom/styx
@Override
public HttpInterceptor build(RouteHandlerDefinition configBlock) {
ImmutableList.Builder<RewriteRule> rules = ImmutableList.builder();
configBlock.config().iterator().forEachRemaining(
node -> {
RewriteConfig rewriteConfig = new JsonNodeConfig(node).as(RewriteConfig.class);
rules.add(rewriteConfig);
}
);
return new RewriteInterceptor(new RewriteRuleset(rules.build()));
}
代码示例来源:origin: epam/NGB
private JsonNode jsonResultParse(String srcJson) throws IOException {
JsonNode root = mapper.readTree(srcJson).path("result");
Iterator<JsonNode> uids = root.path("uids").iterator();
if (uids.hasNext()) {
int uid = uids.next().asInt();
root = root.path("" + uid);
}
return root;
}
代码示例来源:origin: epam/NGB
private JsonNode jsonResultParse(String srcJson) throws IOException {
JsonNode root = new JsonMapper().readTree(srcJson).path("result");
Iterator<JsonNode> uids = root.path("uids").iterator();
if (uids.hasNext()) {
int uid = uids.next().asInt();
root = root.path("" + uid);
}
return root;
}
}
内容来源于网络,如有侵权,请联系作者删除!