当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.elements方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.elements方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.elements方法的具体用法?Java JsonNode.elements怎么用?Java JsonNode.elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.elements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Applies this schema rule to take the not required code generation steps.
 * <p>
 * The not required rule adds a Nullable annotation if JSR-305 annotations are desired.
 *
 * @param nodeName
 *            the name of the schema node for which this "required" rule has
 *            been added
 * @param node
 *            the "not required" node, having a value <code>false</code> or
 *            <code>no value</code>
 * @param generatableType
 *            the class or method which may be marked as "not required"
 * @return the JavaDoc comment attached to the generatableType, which
 *         <em>may</em> have an added not to mark this construct as
 *         not required.
 */
@Override
public JDocCommentable apply(String nodeName, JsonNode node, JDocCommentable generatableType, Schema schema) {

    // Since NotRequiredRule is executed for all fields that do not have "required" present,
    // we need to recognize whether the field is part of the RequiredArrayRule.
    JsonNode requiredArray = schema.getContent().get("required");

    if (requiredArray != null) {
        for (Iterator<JsonNode> iterator = requiredArray.elements(); iterator.hasNext(); ) {
            String requiredArrayItem = iterator.next().asText();
            if (nodeName.equals(requiredArrayItem)) {
                return generatableType;
            }
        }
    }

    if (ruleFactory.getGenerationConfig().isIncludeJsr305Annotations()
            && generatableType instanceof JFieldVar) {
        generatableType.javadoc().append(NOT_REQUIRED_COMMENT_TEXT);
        ((JFieldVar) generatableType).annotate(Nullable.class);
    }

    return generatableType;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:NotRequiredRule.java

示例2: loadArray

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List loadArray(JsonNode array) {
    if (array.isArray()) {
        List list = new ArrayList();
        Iterator iterator = array.elements();
        while (iterator.hasNext()) {
            Object element = iterator.next();
            if (element instanceof JsonNode) {
                list.add(loadObject((JsonNode) element));
            } else {
                list.add(element);
            }
        }
        return list;
    }
    return null;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:18,代码来源:JacksonMapper.java

示例3: removeFieldsExcludedFromEqualsAndHashCode

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Map<String, JFieldVar> removeFieldsExcludedFromEqualsAndHashCode(Map<String, JFieldVar> fields, JsonNode node) {
    Map<String, JFieldVar> filteredFields = new HashMap<String, JFieldVar>(fields);

    JsonNode properties = node.get("properties");

    if (properties != null) {
        if (node.has("excludedFromEqualsAndHashCode")) {
            JsonNode excludedArray = node.get("excludedFromEqualsAndHashCode");

            for (Iterator<JsonNode> iterator = excludedArray.elements(); iterator.hasNext(); ) {
                String excludedPropertyName = iterator.next().asText();
                JsonNode excludedPropertyNode = properties.get(excludedPropertyName);
                filteredFields.remove(ruleFactory.getNameHelper().getPropertyName(excludedPropertyName, excludedPropertyNode));
            }
        }

        for (Iterator<Map.Entry<String, JsonNode>> iterator = properties.fields(); iterator.hasNext(); ) {
            Map.Entry<String, JsonNode> entry = iterator.next();
            String propertyName = entry.getKey();
            JsonNode propertyNode = entry.getValue();

            if (propertyNode.has("excludedFromEqualsAndHashCode") &&
                    propertyNode.get("excludedFromEqualsAndHashCode").asBoolean()) {
                filteredFields.remove(ruleFactory.getNameHelper().getPropertyName(propertyName, propertyNode));
            }
        }
    }

    return filteredFields;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:ObjectRule.java

示例4: convertToHexString

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static String convertToHexString(JsonNode node)
{
    String result = null;
    if (node != null)
    {
        if (node.isArray())
        {
            Iterator<JsonNode> arrayIterator = node.elements();
            StringBuilder sb = new StringBuilder();
            while (arrayIterator.hasNext()) {
                JsonNode elementNode = arrayIterator.next();
                if (elementNode != null)
                {
                    String text = elementNode.asText();
                    if (StringUtils.isNotBlank(text))
                    {
                        byte[] bytes = text.getBytes();
                        if (bytes != null && bytes.length > 0)
                        {
                            sb.append(String.format("%02x", text.getBytes()[0]));
                        }
                    }
                }
            }
            result = sb.toString();
        }
        else
        {
            result = node.asText();
        }
    }

    return result;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:35,代码来源:SampleData.java

示例5: calculateList

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static int calculateList(JsonNode node) {
    int count = 0;
    Iterator<JsonNode> arrayIterator = node.elements();
    while (arrayIterator.hasNext()) {
        JsonNode element = arrayIterator.next();
        if (element.isArray()) {
            count += calculateList(element);
        } else if (element.isContainerNode()) {
            count += calculateDict(element);
        }
    }
    return count;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:14,代码来源:SchemaHistory.java

示例6: parseProperty

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
void parseProperty(@NotNull ArrayGenerator generator, @NotNull JsonArrayProperty property, @NotNull JsonNode node) {
    switch (property) {
        case ITEMS:
            if (node.isArray()) {
                Iterator<JsonNode> nodeIterator = node.elements();
                while (nodeIterator.hasNext()) {
                    addItem(generator, nodeIterator.next());
                }
            } else {
                addItem(generator, node);
            }
            break;
        case ADDITIONAL_ITEMS:
            generator.setAdditionalItems(node.booleanValue());
            break;
        case MAX_ITEMS:
            generator.setMaxItems(node.intValue());
            break;
        case MIN_ITEMS:
            generator.setMinItems(node.intValue());
            break;
        case UNIQUE_ITEMS:
            generator.setUniqueItems(node.booleanValue());
            break;
    }
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:28,代码来源:ArrayParser.java

示例7: findArrayType

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private String findArrayType(JsonNode leafNode) {
	Iterator<JsonNode> nodes = leafNode.elements();
	while(nodes.hasNext()){
		JsonNode node = nodes.next();
		return node.getNodeType().name().toLowerCase();
	}
	return UNKNOWN;
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:9,代码来源:SwaggerModelGenerator.java

示例8: parse

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public N parse(String nodeName, JsonNode jsonNode) {
    if (jsonNode == null) return null;
    // Iterate over node's properties
    Iterator<String> fieldNameIterator = jsonNode.fieldNames();
    while (fieldNameIterator.hasNext()) {
        String fieldName = fieldNameIterator.next();
        if (isProperty(fieldName)) {
            P property = getProperty(fieldName);
            JsonNode propertyNode = jsonNode.get(fieldName);
            if (property == null || propertyNode == null) continue;
            parseProperty(generator, property, propertyNode);
        } else if (isCombinationType(fieldName)) {
            JsonNode combinationNode = jsonNode.get(fieldName);
            if (combinationNode != null && combinationNode.isArray()) {
                JsonSchemaCombinationType type = JsonSchemaCombinationType.get(fieldName);
                List<JsonNode> combinationNodes = new ArrayList<>();
                Iterator<JsonNode> combinationNodeIterator = combinationNode.elements();
                while (combinationNodeIterator.hasNext()) {
                    combinationNodes.add(combinationNodeIterator.next());
                }
                generator.combine(type, combinationNodes);
            }
        }
    }
    return getNode(nodeName, generator);
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:28,代码来源:BaseJsonNodeParser.java

示例9: convertConditionRecord

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Generates a condition instance for each condition type under the
 * Condition Json node.
 *
 * @param conditions
 *            the complete list of conditions
 * @param conditionType
 *            the condition type for the condition being created.
 * @param conditionNode
 *            each condition node to be parsed.
 */
private void convertConditionRecord(List<Condition> conditions,
        String conditionType, JsonNode conditionNode) {

    Iterator<Map.Entry<String, JsonNode>> mapOfFields = conditionNode
            .fields();
    List<String> values;
    Entry<String, JsonNode> field;
    JsonNode fieldValue;
    Iterator<JsonNode> elements;

    while (mapOfFields.hasNext()) {
        values = new LinkedList<String>();
        field = mapOfFields.next();
        fieldValue = field.getValue();

        if (fieldValue.isArray()) {
            elements = fieldValue.elements();
            while (elements.hasNext()) {
                values.add(elements.next().asText());
            }
        } else {
            values.add(fieldValue.asText());
        }
        conditions.add(new Condition().withType(conditionType)
                .withConditionKey(field.getKey()).withValues(values));
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:39,代码来源:JsonPolicyReader.java

示例10: getIds

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private List<Long> getIds(JsonNode node) {
    List<Long> ids = new ArrayList<>();
    Iterator<JsonNode> idNodes = node.elements();
    while (idNodes.hasNext()) {
        ids.add(idNodes.next().asLong());
    }
    return ids;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:9,代码来源:CmRestController.java

示例11: jsonToLatLong

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Create {@link LatLong} from a jsonNode object and parse it to get GPS coordinates
 *
 * @param jsonCoordinates json coordinates to parse
 * @return {@link LatLong} the parsed latlong from jsonCoordinates
 */
private static LatLong jsonToLatLong(JsonNode jsonCoordinates) {
    JsonNode main = jsonCoordinates.elements().next();
    JsonNode coords = main.elements().next();
    Iterator<JsonNode> characteristics = coords.elements();
    double latitude = characteristics.next().asDouble();
    double longitude = characteristics.next().asDouble();
    return new LatLong(latitude, longitude);
}
 
开发者ID:IKB4Stream,项目名称:IKB4Stream,代码行数:15,代码来源:TwitterMock.java

示例12: parseArray

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static List<C4CTicket> parseArray(String content) throws JsonProcessingException, IOException {
	List<C4CTicket> c4cTickets = new ArrayList<>();
	ObjectMapper mapper = new ObjectMapper();
	JsonNode parentNode = mapper.readTree(content).findValue(RESULTS_JSON_TREE_NODE);
	Iterator<JsonNode> iterator = parentNode.elements();
	while (iterator.hasNext()) {
		JsonNode jNode = iterator.next();
		c4cTickets.add(createC4CTicketObject(jNode));
	}
	return c4cTickets;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:12,代码来源:C4CTicketService.java

示例13: convertConditionRecord

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Generates a condition instance for each condition type under the
 * Condition Json node.
 *
 * @param conditions
 *            the complete list of conditions
 * @param conditionType
 *            the condition type for the condition being created.
 * @param conditionNode
 *            each condition node to be parsed.
 */
private void convertConditionRecord(List<Condition> conditions,
                                    String conditionType, JsonNode conditionNode) {

    Iterator<Map.Entry<String, JsonNode>> mapOfFields = conditionNode
            .fields();
    List<String> values;
    Entry<String, JsonNode> field;
    JsonNode fieldValue;
    Iterator<JsonNode> elements;

    while (mapOfFields.hasNext()) {
        values = new LinkedList<String>();
        field = mapOfFields.next();
        fieldValue = field.getValue();

        if (fieldValue.isArray()) {
            elements = fieldValue.elements();
            while (elements.hasNext()) {
                values.add(elements.next().asText());
            }
        } else {
            values.add(fieldValue.asText());
        }
        conditions.add(new Condition().withType(conditionType)
                                      .withConditionKey(field.getKey()).withValues(values));
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:39,代码来源:JsonPolicyReader.java

示例14: principalOf

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Generates a list of principals from the Principal Json Node
 *
 * @param principalNodes
 *            the principal Json to be parsed
 * @return a list of principals
 */
private List<Principal> principalOf(JsonNode principalNodes) {
    List<Principal> principals = new LinkedList<Principal>();

    if (principalNodes.asText().equals("*")) {
        principals.add(Principal.All);
        return principals;
    }

    Iterator<Map.Entry<String, JsonNode>> mapOfPrincipals = principalNodes
            .fields();
    String schema;
    JsonNode principalNode;
    Entry<String, JsonNode> principal;
    Iterator<JsonNode> elements;
    while (mapOfPrincipals.hasNext()) {
        principal = mapOfPrincipals.next();
        schema = principal.getKey();
        principalNode = principal.getValue();

        if (principalNode.isArray()) {
            elements = principalNode.elements();
            while (elements.hasNext()) {
                principals.add(createPrincipal(schema, elements.next()));
            }
        } else {
            principals.add(createPrincipal(schema, principalNode));
        }
    }

    return principals;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:39,代码来源:JsonPolicyReader.java

示例15: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public JDefinedClass apply(String nodeName, JsonNode node, JDefinedClass jclass, Schema schema) {
    List<String> requiredFieldMethods = new ArrayList<String>();

    JsonNode properties = schema.getContent().get("properties");

    for (Iterator<JsonNode> iterator = node.elements(); iterator.hasNext(); ) {
        String requiredArrayItem = iterator.next().asText();
        if (requiredArrayItem.isEmpty()) {
            continue;
        }

        JsonNode propertyNode = null;

        if (properties != null) {
            propertyNode = properties.findValue(requiredArrayItem);
        }

        String fieldName = ruleFactory.getNameHelper().getPropertyName(requiredArrayItem, propertyNode);
        JFieldVar field = jclass.fields().get(fieldName);

        if (field == null) {
            continue;
        }

        addJavaDoc(field);

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()) {
            addNotNullAnnotation(field);
        }

        if (ruleFactory.getGenerationConfig().isIncludeJsr305Annotations()) {
            addNonnullAnnotation(field);
        }

        requiredFieldMethods.add(getGetterName(fieldName, field.type(), node));
        requiredFieldMethods.add(getSetterName(fieldName, node));
    }

    updateGetterSetterJavaDoc(jclass, requiredFieldMethods);

    return jclass;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:RequiredArrayRule.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.elements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。