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


Java ObjectNode.fields方法代碼示例

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


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

示例1: isObjectNodeSubset

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Returns true if expected is a subset of returned
 *
 * This is used for JSON serialiser comparisons.
 *
 * @param expected
 * @param returned
 * @return
 */
protected boolean isObjectNodeSubset(ObjectNode expected, ObjectNode returned) {

    Iterator<Entry<String, JsonNode>> expectedChildren = expected.fields();

	for (Map.Entry<String, JsonNode> en; expectedChildren.hasNext();) {
		en = expectedChildren.next();
        String key = en.getKey();
        JsonNode value = en.getValue();

        JsonNode returnedValue = returned.get(key);

        if (returnedValue == null) {
		errorDescription = "Returned JSON does not have key '" + key +"', with expected value:\n" + value.toString();
		return false;
        } else if (!isJsonNodeSubset(value, returnedValue)) {
		return false;
        }
	}
    return true;
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:30,代碼來源:SubsetStatus.java

示例2: evalObject

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的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: JsonObjectExpression

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
protected JsonObjectExpression(ObjectNode o)
{
	super();
	final Iterator<Entry<String, JsonNode>> it = o.fields();
	while( it.hasNext() )
	{
		final Entry<String, JsonNode> e = it.next();
		final String name = e.getKey();
		final JsonNode n = e.getValue();
		if( n.isObject() )
		{
			put(name, new JsonObjectExpression((ObjectNode) n));
		}
		else if( n.isInt() )
		{
			put(name, n.asInt());
		}
		else if( n.isFloatingPointNumber() )
		{
			put(name, n.asDouble());
		}
		else if( n.isBoolean() )
		{
			put(name, n.asBoolean());
		}
		else
		{
			put(name, n.asText());
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:32,代碼來源:TinyMceAddonServiceImpl.java

示例4: annotation

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Returns annotation of Ports on which LinkDiscovery is suppressed.
 *
 * @return key-value pairs of annotation
 */
public Map<String, String> annotation() {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();

    String jsonAnnotation = get(ANNOTATION, null);
    if (jsonAnnotation == null || jsonAnnotation.isEmpty()) {
        return ImmutableMap.of();
    }

    JsonNode annotationNode;
    try {
        annotationNode = MAPPER.readTree(jsonAnnotation);
    } catch (IOException e) {
        log.error("Failed to read JSON tree from: {}", jsonAnnotation);
        return ImmutableMap.of();
    }

    if (annotationNode.isObject()) {
        ObjectNode obj = (ObjectNode) annotationNode;
        Iterator<Map.Entry<String, JsonNode>> it = obj.fields();
        while (it.hasNext()) {
            Map.Entry<String, JsonNode> entry = it.next();
            final String key = entry.getKey();
            final JsonNode value = entry.getValue();

            if (value.isValueNode()) {
                if (value.isNull()) {
                    builder.put(key, SuppressionRules.ANY_VALUE);
                } else {
                    builder.put(key, value.asText());
                }
            } else {
                log.warn("Encountered unexpected JSON field {} for annotation", entry);
            }
        }
    } else {
        log.error("Encountered unexpected JSONNode {} for annotation", annotationNode);
        return ImmutableMap.of();
    }

    return builder.build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:47,代碼來源:SuppressionConfig.java


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