當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonNode.isArray方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.JsonNode.isArray方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonNode.isArray方法的具體用法?Java JsonNode.isArray怎麽用?Java JsonNode.isArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.isArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateAssignProp

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public static void updateAssignProp(JsonNode props) throws IOException, SQLException, DataAccessException {
    String name = props.get("scheme").asText();
    JsonNode propNode = props.findPath("properties");
    String propString = recProp("prop." + name) + ",";
    if (propNode.isArray()) {
        for (JsonNode p : propNode) {
            propString = propString + p.textValue() + ",";
        }
        propString = propString.substring(0, propString.length() - 1);
    } else if (propNode.isTextual()) {
        propString = propString + propNode.textValue();
    } else {
        Logger.error("passed property neither a list or array");
        throw new IllegalArgumentException();
    }
    chngProp("prop." + name, propString);
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:18,代碼來源:PropertyDao.java

示例2: evalObject

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private void evalObject(ObjectNode source, ObjectNode target, RenderContext context,
	ScriptContext scriptContext)
{
	final Iterator<Entry<String, JsonNode>> it = source.fields();
	while( it.hasNext() )
	{
		final Entry<String, JsonNode> e = it.next();
		final String name = e.getKey();
		final JsonNode n = e.getValue();
		if( n.isObject() )
		{
			// recursively handle it
			final ObjectNode nt = jsonMapper.createObjectNode();
			target.put(name, nt);
			evalObject((ObjectNode) n, nt, context, scriptContext);
		}
		else if( n.isInt() || n.isLong() )
		{
			target.put(name, n.asInt());
		}
		else if( n.isFloatingPointNumber() || n.isDouble() )
		{
			target.put(name, n.asDouble());
		}
		else if( n.isBoolean() )
		{
			target.put(name, n.asBoolean());
		}
		else if( n.isArray() )
		{
			target.putArray(name).addAll((ArrayNode) n);
		}
		else
		{
			// freemarker eval
			target.put(name, evaluateMarkUp(context, n.asText(), scriptContext));
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:40,代碼來源:TinyMceAddonServiceImpl.java

示例3: 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

示例4: deserialize

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * JsonNode convert into UpdateNotification.
 * @param node the "params" node of UpdateNotification JsonNode
 */
private UpdateNotification deserialize(JsonNode node) {
    if (node.isArray()) {
        if (node.size() == 2) {
            return new UpdateNotification(node.get(0).asText(), node.get(1));
        }
    }
    return null;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:UpdateNotificationConverter.java

示例5: pathAll

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * PathAll matcher that checks if each element of the final
 * result matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if all elements of the final result matches
 *         the expected result, False otherwise
 */
public static boolean pathAll(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (!element.equals(expectedResult)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:26,代碼來源:AcceptorPathMatcher.java

示例6: validateFilters

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private void validateFilters(JsonNode filtersJson) {
    if (filtersJson == null || filtersJson.isNull()) {
        throw new IncorrectParameterException("Rule filters are required!");
    }
    if (!filtersJson.isArray()) {
        throw new IncorrectParameterException("Filters json is not an array!");
    }
    ArrayNode filtersArray = (ArrayNode) filtersJson;
    for (int i = 0; i < filtersArray.size(); i++) {
        validateComponentJson(filtersArray.get(i), ComponentType.FILTER);
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:13,代碼來源:BaseRuleService.java

示例7: 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

示例8: list

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public static Result list() {  
    try {
        List<Instructor> objects = Instructor.getInstructorsList();
        JsonNode jsonObjects = Instructor.jsonInstructorsListSerialization(objects);
        if (jsonObjects.isArray()) {
            int i = 0;
            for (JsonNode object : jsonObjects) {
                ((ObjectNode)object).put("person", objects.get(i).getPerson().jsonSerialization());
                int j = 0;
                ((ArrayNode)(object.get("allocations"))).removeAll();
                for (Allocation allocation : objects.get(i).getAllocations()) {
                    JsonNode allocationNode = allocation.jsonSerialization();
                    JsonNode courseSessionNode = allocation.getCourseSession().jsonSerialization();
                    JsonNode course = allocation.getCourseSession().getCourse().jsonSerialization();
                    ((ObjectNode)courseSessionNode).put("course", course);                        
                    ((ObjectNode)allocationNode).put("courseSession", courseSessionNode);
                    ((ArrayNode)(object.get("allocations"))).add(allocationNode);
                    j++;
                }
                i++;
            }
        }
        return ok(jsonObjects);
    }catch(Exception e) {
        appLogger.error("Error listing objects",e);
        return internalServerError("Error listing objects"); 
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:29,代碼來源:Instructors.java

示例9: resourcesOf

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Generates a list of resources from the Resource Json Node.
 *
 * @param resourceNodes
 *            the resource Json node to be parsed.
 * @return the list of resources.
 */
private List<Resource> resourcesOf(JsonNode resourceNodes) {
    List<Resource> resources = new LinkedList<>();

    if (resourceNodes.isArray()) {
        for (JsonNode resource : resourceNodes) {
            resources.add(new Resource(resource.asText()));
        }
    } else {
        resources.add(new Resource(resourceNodes.asText()));
    }

    return resources;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:21,代碼來源:JsonPolicyReader.java

示例10: convert

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public List<DeviceData> convert(String topic, MqttMessage msg) throws Exception {
    String data = new String(msg.getPayload(), StandardCharsets.UTF_8);
    log.trace("Parsing json message: {}", data);

    if (!filterExpression.isEmpty()) {
        try {
            log.debug("Data before filtering {}", data);
            DocumentContext document = JsonPath.parse(data);
            document = JsonPath.parse((Object) document.read(filterExpression));
            data = document.jsonString();
            log.debug("Data after filtering {}", data);
        } catch (RuntimeException e) {
            log.debug("Failed to apply filter expression: {}", filterExpression);
            throw new RuntimeException("Failed to apply filter expression " + filterExpression);
        }
    }

    JsonNode node = mapper.readTree(data);
    List<String> srcList;
    if (node.isArray()) {
        srcList = new ArrayList<>(node.size());
        for (int i = 0; i < node.size(); i++) {
            srcList.add(mapper.writeValueAsString(node.get(i)));
        }
    } else {
        srcList = Collections.singletonList(data);
    }

    return parse(topic, srcList);
}
 
開發者ID:thingsboard,項目名稱:thingsboard-gateway,代碼行數:32,代碼來源:MqttJsonConverter.java

示例11: getNumberOfEmbeddedAssociations

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public long getNumberOfEmbeddedAssociations(SessionFactory sessionFactory) {
	RedisClusterCommands<String, String> connection = getConnection( sessionFactory );

	long associationCount = 0;
	List<String> keys = connection.keys( "*" );

	for ( String key : keys ) {

		if ( key.startsWith( AbstractRedisDialect.ASSOCIATIONS ) || key.startsWith( AbstractRedisDialect.IDENTIFIERS ) ) {
			continue;
		}

		String type = connection.type( key );

		if ( "string".equalsIgnoreCase( type ) ) {
			String value = connection.get( key );
			JsonNode jsonNode = fromJSON( value );

			for ( JsonNode node : jsonNode ) {
				if ( node.isArray() ) {
					associationCount++;
				}
			}
		}
	}

	return associationCount;
}
 
開發者ID:hibernate,項目名稱:hibernate-ogm-redis,代碼行數:29,代碼來源:RedisTestHelper.java

示例12: findFirstByMarker

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Finds the first log with marker name
 *
 * @param marker the marker name
 * @return the tree node
 * @throws IOException Signals that an I/O exception has occurred.
 */
public JsonNode findFirstByMarker(String marker) throws IOException {
	JsonNode hits = this.query(String.format("{\"query\": {\"match\": {\"marker.name\": \"%s\"}},\"size\": 1,\"sort\":[{\"message.keyword\":{\"order\":\"asc\"}}]}", marker));
	assertNotNull(hits);
	if (hits.isArray() && hits.size() > 0) {
		return hits.get(0).get("_source");
	} else {
		return null;
	}
}
 
開發者ID:magrossi,項目名稱:es-log4j2-appender,代碼行數:17,代碼來源:ElasticSearchRestAppenderTest.java

示例13: 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

示例14: updateDatasetDeployment

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public static void updateDatasetDeployment(JsonNode root)
    throws Exception {
  final JsonNode deployment = root.path("deploymentInfo");
  if (deployment.isMissingNode() || !deployment.isArray()) {
    throw new IllegalArgumentException(
        "Dataset deployment info update error, missing necessary fields: " + root.toString());
  }

  final Object[] idUrn = findDataset(root);
  if (idUrn[0] == null || idUrn[1] == null) {
    throw new IllegalArgumentException("Cannot identify dataset from id/uri/urn: " + root.toString());
  }
  final Integer datasetId = (Integer) idUrn[0];
  final String urn = (String) idUrn[1];

  ObjectMapper om = new ObjectMapper();
  // om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);

  for (final JsonNode deploymentInfo : deployment) {
    DeploymentRecord record = om.convertValue(deploymentInfo, DeploymentRecord.class);
    record.setDatasetId(datasetId);
    record.setDatasetUrn(urn);
    record.setModifiedTime(System.currentTimeMillis() / 1000);
    DEPLOYMENT_WRITER.append(record);
  }

  // remove old info then insert new info
  DEPLOYMENT_WRITER.execute(DELETE_DATASET_DEPLOYMENT_BY_DATASET_ID, new Object[]{datasetId});
  DEPLOYMENT_WRITER.insert();
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:31,代碼來源:DatasetInfoDao.java

示例15: actionsOf

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Generates a list of actions from the Action Json Node.
 *
 * @param actionNodes
 *            the action Json node to be parsed.
 * @return the list of actions.
 */
private List<Action> actionsOf(JsonNode actionNodes) {
    List<Action> actions = new LinkedList<Action>();

    if (actionNodes.isArray()) {
        for (JsonNode action : actionNodes) {
            actions.add(new NamedAction(action.asText()));
        }
    } else {
        actions.add(new NamedAction(actionNodes.asText()));
    }
    return actions;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:20,代碼來源:JsonPolicyReader.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.isArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。