本文整理了Java中org.codehaus.jackson.node.ArrayNode.getElements()
方法的一些代码示例,展示了ArrayNode.getElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayNode.getElements()
方法的具体详情如下:
包路径:org.codehaus.jackson.node.ArrayNode
类名称:ArrayNode
方法名:getElements
暂无
代码示例来源:origin: sirensolutions/siren
/**
* The generateFacetsForLeaves() method for processing json arrays, simply delegates for each array element.
*/
private void generateFacetsForLeaves(ArrayNode array, String fieldName, ExtendedJsonField field, String path,
List<SirenFacetEntry> facets) {
Iterator<JsonNode> iterator = array.getElements();
while (iterator.hasNext()) {
JsonNode node = iterator.next();
generateFacetsForLeaves(node, fieldName, field, path, facets);
}
}
代码示例来源:origin: NGDATA/hbase-indexer
public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException {
ArrayNode arrayNode = getArray(node, prop, null);
if (arrayNode == null) {
return defaultValue;
}
List<String> elements = new ArrayList<String>();
Iterator<JsonNode> elementItr = arrayNode.getElements();
while (elementItr.hasNext()) {
elements.add(elementItr.next().getValueAsText());
}
return elements;
}
}
代码示例来源:origin: NGDATA/lilyproject
public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException {
ArrayNode arrayNode = getArray(node, prop, null);
if (arrayNode == null) {
return defaultValue;
}
List<String> elements = new ArrayList<String>();
Iterator<JsonNode> elementItr = arrayNode.getElements();
while (elementItr.hasNext()) {
elements.add(elementItr.next().asText());
}
return elements;
}
代码示例来源:origin: com.ngdata/hbase-indexer-model
public List<IndexerDefinitionBuilder> fromJsonBytes(byte [] json) {
List<IndexerDefinitionBuilder> builders = new ArrayList<IndexerDefinitionBuilder>();
ArrayNode node;
try {
node = (ArrayNode) new ObjectMapper().readTree(new ByteArrayInputStream(json));
} catch (IOException e) {
throw new RuntimeException("Error parsing indexer definition JSON.", e);
}
Iterator<JsonNode> it = node.getElements();
while (it.hasNext()) {
JsonNode nextNode = it.next();
builders.add(IndexerDefinitionJsonSerDeser.INSTANCE.fromJson((ObjectNode)nextNode));
}
return builders;
}
}
代码示例来源:origin: stackoverflow.com
ArrayNode users = (ArrayNode) root.path("users");
Iterator<JsonNode> iterator = users.getElements();
while (iterator.hasNext()) {
User user = mapper.readValue(iterator.next(), User.class);
代码示例来源:origin: com.ngdata/hbase-indexer-common
public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException {
ArrayNode arrayNode = getArray(node, prop, null);
if (arrayNode == null || arrayNode.isNull()) {
return defaultValue;
}
List<String> elements = new ArrayList<String>();
Iterator<JsonNode> elementItr = arrayNode.getElements();
while (elementItr.hasNext()) {
elements.add(elementItr.next().getValueAsText());
}
return elements;
}
}
代码示例来源:origin: hoverruan/weiboclient4j
public static List<UserTagList> parse(ArrayNode arrayNode) {
List<UserTagList> result = new ArrayList<UserTagList>(arrayNode.size());
Iterator<JsonNode> elements = arrayNode.getElements();
while (elements.hasNext()) {
JsonNode json = elements.next();
long userId = json.get("id").asLong();
List<Tag> tags = Tag.parseTags(json.get("tags"));
UserTagList userTagList = new UserTagList(userId, tags);
result.add(userTagList);
}
return result;
}
}
代码示例来源:origin: io.sphere/sphere-java-client
/** Very simple way to "erase" passwords -
* replaces all field values whose names contains {@code 'pass'} by {@code 'xxxxx'}. */
private static JsonNode secure(JsonNode node) {
if (node.isObject()) {
ObjectNode objectNode = (ObjectNode)node;
Iterator<Map.Entry<String, JsonNode>> fields = node.getFields();
while (fields.hasNext()) {
Map.Entry<String, JsonNode> field = fields.next();
if (field.getValue().isTextual() && field.getKey().toLowerCase().contains("pass")) {
objectNode.put(field.getKey(), "xxxxx");
} else {
secure(field.getValue());
}
}
return objectNode;
} else if (node.isArray()) {
ArrayNode arrayNode = (ArrayNode)node;
Iterator<JsonNode> elements = arrayNode.getElements();
while (elements.hasNext()) {
secure(elements.next());
}
return arrayNode;
} else {
return node;
}
}
代码示例来源:origin: gravel-st/gravel
private static Object jsonNodeAsSimpleObject(JsonNode value) {
Object o = null;
if (value.isTextual()) {
o = value.asText();
} else if (value.isArray()) {
ArrayList<Object> arrayList = new ArrayList<>();
for (Iterator<JsonNode> iter = ((ArrayNode) value).getElements(); iter
.hasNext();) {
arrayList.add(jsonNodeAsSimpleObject(iter.next()));
}
o = arrayList.toArray();
} else if (value.isNull()) {
o = null;
} else if (value.isObject()) {
HashMap<String, Object> map = new HashMap<String, Object>();
final Iterator<Entry<String, JsonNode>> fields = value.getFields();
while (fields.hasNext()) {
final Entry<String, JsonNode> next = fields.next();
map.put(next.getKey(), jsonNodeAsSimpleObject(next.getValue()));
}
o = map;
} else
throw new RuntimeException("Unknown type: " + value);
return o;
}
代码示例来源:origin: sirensolutions/siren
private JsonNode projection(JsonNode node, String relativePath) {
if (relativePath == null || relativePath.length() == 0) {
return node;
}
if (node.isArray()) {
ArrayNode arrayNode = mapper.createArrayNode();
Iterator<JsonNode> elementsIterator = ((ArrayNode) node).getElements();
while (elementsIterator.hasNext()) {
ObjectNode oNode = mapper.createObjectNode();
oNode.put(lastPartOfPath(relativePath), projection(elementsIterator.next(), relativePath));
arrayNode.add(oNode);
}
return arrayNode;
} else {
int firstDotPosition = relativePath.indexOf('.');
if (firstDotPosition == -1) {
return node.get(relativePath);
} else {
return projection(node.get(relativePath.substring(0, firstDotPosition)),
relativePath.substring(firstDotPosition + 1));
}
}
}
代码示例来源:origin: apache/helix
private Map<String, JobConfig.Builder> getJobConfigs(ArrayNode root)
throws HelixException, IOException {
Map<String, JobConfig.Builder> jobConfigsMap = new HashMap<>();
for (Iterator<JsonNode> it = root.getElements(); it.hasNext(); ) {
JsonNode job = it.next();
ZNRecord record = null;
try {
record = toZNRecord(job.toString());
} catch (IOException e) {
// Ignore the parse since it could be just simple fields
}
if (record == null || record.getSimpleFields().isEmpty()) {
Map<String, String> cfgMap = OBJECT_MAPPER.readValue(job.toString(),
TypeFactory.defaultInstance()
.constructMapType(HashMap.class, String.class, String.class));
jobConfigsMap
.put(job.get(Properties.id.name()).getTextValue(), JobAccessor.getJobConfig(cfgMap));
} else {
jobConfigsMap
.put(job.get(Properties.id.name()).getTextValue(), JobAccessor.getJobConfig(record));
}
}
return jobConfigsMap;
}
}
代码示例来源:origin: eBay/YiDB
ArrayNode child = (ArrayNode) root.get(metaType);
List<JsonNode> loadList = new ArrayList<JsonNode>();
Iterator<JsonNode> instIter = child.getElements();
rawData.put(metaType, loadList);
while (instIter.hasNext()) {
代码示例来源:origin: com.googlecode.etl-unit/json-validator
private void readTypeNode(ObjectNode node) throws JsonSchemaValidationException {
JsonNode typeNode = node.get("type");
if (typeNode != null)
{
if (typeNode.isArray())
{
Iterator<JsonNode> it = ((ArrayNode) typeNode).getElements();
while (it.hasNext())
{
JsonNode vnode = it.next();
if (!vnode.isTextual())
{
throw new JsonSchemaValidationException("Invalid type union. Item is not textual", "", typeNode, null);
}
addTypeValue(vnode.asText());
}
}
else if (typeNode.isTextual())
{
addTypeValue(typeNode.asText());
}
else
{
throw new JsonSchemaValidationException("Invalid schema - invalid object type", "", typeNode, null);
}
}
}
代码示例来源:origin: net.sf.jsog/jsog
if (jsonNode.isArray()) {
ArrayNode array = (ArrayNode) jsonNode;
Iterator<JsonNode> it = array.getElements();
value = new ArrayList<Object>();
while (it.hasNext()) {
代码示例来源:origin: eBay/YiDB
Iterator<JsonNode> nodeIter = arrayNode.getElements();
while(nodeIter.hasNext()) {
JsonNode valNode = nodeIter.next();
内容来源于网络,如有侵权,请联系作者删除!