当前位置: 首页>>代码示例>>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;未经允许,请勿转载。