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


Java JsonNode.isObject方法代码示例

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


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

示例1: deserialize

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public T deserialize(JsonParser jsonParser,
                     DeserializationContext deserializationContext) throws IOException,
        JsonProcessingException {
    ObjectCodec objectCodec = jsonParser.getCodec();
    JsonNode node = objectCodec.readTree(jsonParser);
    Class<? extends T> typeClass = null;
    if (node.isObject() && node.has("type")) {
        JsonNode type = node.get("type");
        if (type != null && type.isTextual()) {
            typeClass = registry.get(type.textValue());
        }
    }

    if (typeClass == null) {
        return null;
    }

    StringWriter writer = new StringWriter();
    objectMapper.writeValue(writer, node);
    writer.close();
    String json = writer.toString();
    return objectMapper.readValue(json, typeClass);
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:25,代码来源:AbstractTypedObjectDeserializer.java

示例2: jsonToQuarkResult

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * 将json转换为QuarkResult
 * @param json
 * @param clazz
 * @return
 */
public static QuarkResult jsonToQuarkResult(String json, Class<?> clazz) {

    try {
        if (clazz == null) {
            return MAPPER.readValue(json, QuarkResult.class);
        }

        JsonNode jsonNode = MAPPER.readTree(json);
        JsonNode data = jsonNode.get("data");
        Object obj = null;
        if (clazz != null) {
            if (data.isObject()) {
                obj = MAPPER.readValue(data.traverse(), clazz);
            } else if (data.isTextual()) {
                obj = MAPPER.readValue(data.asText(), clazz);
            }
        }

        return new QuarkResult(jsonNode.get("status").intValue(), obj, jsonNode.get("error").asText());
    } catch (IOException e) {
        return null;
    }

}
 
开发者ID:ChinaLHR,项目名称:JavaQuarkBBS,代码行数:31,代码来源:JsonUtils.java

示例3: findByCohort

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Traverses the argument {@link JsonNode} to find any contained
 * {@code JsonNode JsonNodes} which match the argument cohort, if
 * present.
 *
 * If {@code node} is an {@code ArrayNode}, then the array is
 * traversed and the first matching filter node, if any, is
 * returned.
 *
 * @param node A {@code JsonNode} to traverse in search of cohort
 *        information.
 * @param cohortOpt An optional cohort string to match against the
 *        argument {@code JsonNode}.
 * @return A {@code JsonNode} matching the specified cohort, or else
 *         {@link MissingNode}.
 */
public static JsonNode findByCohort(JsonNode node, Optional<String> cohortOpt) {
  if (node.isObject() && ToggleJsonNode.matchesCohort(node, cohortOpt)) {
    return node;
  } else if (node.isArray()) {
    final Iterator<JsonNode> iterator = node.elements();

    while (iterator.hasNext()) {
      final JsonNode containedNode = iterator.next();
      if (containedNode.isObject() && ToggleJsonNode.matchesCohort(containedNode, cohortOpt)) {
        return containedNode;
      }
    }

    return MissingNode.getInstance();
  } else {
    return MissingNode.getInstance();
  }
}
 
开发者ID:whiskerlabs,项目名称:toggle,代码行数:35,代码来源:ToggleJsonNode.java

示例4: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
JsonNode apply(JsonNode node) {
    final JsonNode actual = ensureExistence(node);
    if (!EQUIVALENCE.equivalent(actual, oldValue)) {
        throw new JsonPatchException("mismatching value at '" + path + "': " +
                                     actual + " (expected: " + oldValue + ')');
    }
    final JsonNode replacement = newValue.deepCopy();
    if (path.toString().isEmpty()) {
        return replacement;
    }
    final JsonNode parent = node.at(path.head());
    final String rawToken = path.last().getMatchingProperty();
    if (parent.isObject()) {
        ((ObjectNode) parent).set(rawToken, replacement);
    } else {
        ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement);
    }
    return node;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:21,代码来源:SafeReplaceOperation.java

示例5: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
JsonNode apply(final JsonNode node) {
    ensureExistence(node);

    final JsonNode replacement = valueCopy();
    if (path.toString().isEmpty()) {
        return replacement;
    }
    final JsonNode parent = node.at(path.head());
    final String rawToken = path.last().getMatchingProperty();
    if (parent.isObject()) {
        ((ObjectNode) parent).set(rawToken, replacement);
    } else {
        ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement);
    }
    return node;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:18,代码来源:ReplaceOperation.java

示例6: configureRemoteCollection

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public boolean configureRemoteCollection ( int collectHostIndex, StringBuffer resultsBuf ) {

		JsonNode remoteCollectionsDefinition = getAttributeAsJson( ServiceAttributes.remoteCollections );

		JsonNode remoteDefinition = remoteCollectionsDefinition.get( collectHostIndex );

		if ( !remoteDefinition.isObject() || !remoteDefinition.has( "host" ) || !remoteDefinition.has( "port" ) ) {
			logger.error( "Invalid configuration: {}", remoteDefinition.toString() );
			updateServiceParseResults(
				resultsBuf, CSAP.CONFIG_PARSE_WARN,
				getErrorHeader()
						+ "Invalid format for " + ServiceAttributes.remoteCollections
						+ " expected: host and port, found: " + remoteCollectionsDefinition.toString() );
			return false;
		}

		setCollectHost( remoteDefinition.get( "host" ).asText() );
		setCollectPort( remoteDefinition.get( "port" ).asText() );
		return true;

	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:22,代码来源:ServiceBaseParser.java

示例7: getTaskFromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Task getTaskFromJson(JsonNode node) throws JsonProcessingException {
	if (node.isObject()) {
		ObjectNode onode = (ObjectNode) node;
		final JsonNode type = onode.remove("type");
		final JsonNode attributes = onode.remove("attributes");
		final JsonNode relationships = onode.remove("relationships");
		final JsonNode links = onode.remove("links");
		Iterator<Map.Entry<String, JsonNode>> fields = attributes.fields();
		while (fields.hasNext()) {
			Map.Entry<String, JsonNode> f = fields.next();
			onode.put(f.getKey(), f.getValue().textValue());
		}
		return mapper.treeToValue(onode, Task.class);
	}
	else {
		throw new JsonMappingException("Not an object: " + node);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:19,代码来源:JerseyApplicationTest.java

示例8: setFullEntitlementQuota

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Sets Full quota of the user available entitlements.
 * @param node object containing full quota of user available entitlements.
 * @throws Exception if could not parse node object
 */
@JsonSetter("full_entitlement_quota")
public void setFullEntitlementQuota(
        final JsonNode node) throws Exception {
    if (node != null && node.isObject()) {
            ObjectMapper mapper = new ObjectMapper();
            this.mFullEntitlementQuota = mapper.readValue(
                    node.toString(), LicenseEntitlementQuota.class);
    }
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:15,代码来源:LicenseEntitlement.java

示例9: setCategory

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Sets category of the media.
 *
 * @param node
 *            category of the media
 */
@JsonSetter("category")
public void setCategory(final JsonNode node) {
    if (node != null) {
        if (node.isObject()) {
            Integer id = node.get("id").intValue();
            String name = node.get("name").asText();
            this.mCategory = new StockFileCategory(id, name);
        }
    }
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:17,代码来源:StockFile.java

示例10: schemaFromExample

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public ObjectNode schemaFromExample(JsonNode example) {

        if (example.isObject()) {
            return objectSchema(example);
        } else if (example.isArray()) {
            return arraySchema(example);
        } else {
            return simpleTypeSchema(example);
        }

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SchemaGenerator.java

示例11: jsonToConnect

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private SchemaAndValue jsonToConnect(JsonNode jsonValue) {
    if (jsonValue == null)
        return SchemaAndValue.NULL;

    if (!jsonValue.isObject() || jsonValue.size() != 2 || !jsonValue.has(JsonSchema.ENVELOPE_SCHEMA_FIELD_NAME) || !jsonValue.has(JsonSchema.ENVELOPE_PAYLOAD_FIELD_NAME))
        throw new DataException("JSON value converted to Kafka Connect must be in envelope containing schema");

    Schema schema = asConnectSchema(jsonValue.get(JsonSchema.ENVELOPE_SCHEMA_FIELD_NAME));
    return new SchemaAndValue(schema, convertToConnect(schema, jsonValue.get(JsonSchema.ENVELOPE_PAYLOAD_FIELD_NAME)));
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:11,代码来源:JsonConverter.java

示例12: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
JsonNode apply(final JsonNode node) {
    if (from.equals(path)) {
        return node;
    }
    if (node.at(from).isMissingNode()) {
        throw new JsonPatchException("non-existent source path: " + from);
    }

    final JsonNode sourceParent = ensureSourceParent(node, from);

    // Remove
    final String raw = from.last().getMatchingProperty();
    final JsonNode source;
    if (sourceParent.isObject()) {
        source = ((ObjectNode) sourceParent).remove(raw);
    } else {
        source = ((ArrayNode) sourceParent).remove(Integer.parseInt(raw));
    }

    // Add
    if (path.toString().isEmpty()) {
        return source;
    }

    final JsonNode targetParent = ensureTargetParent(node, path);
    return targetParent.isArray() ? AddOperation.addToArray(path, node, source)
                                  : AddOperation.addToObject(path, node, source);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:30,代码来源:MoveOperation.java

示例13: matches

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private MatchType matches(JsonNode datum, Schema schema) {
  switch (schema.getType()) {
  case RECORD:
    if (datum.isObject()) {
      return matchRecord(datum, schema);
    }
    break;
  case UNION:
    return resolveUnion(datum, schema.getTypes()).matchType;
  case MAP:
    if (datum.isObject()) {
      return matchMapValue(datum, schema);
    }
    break;
  case ARRAY:
    if (datum.isArray()) {
      return matchArrayElement(datum, schema);
    }
    break;
  case BOOLEAN:
    if (datum.isBoolean()) {
      return MatchType.FULL;
    }
    break;
  case FLOAT:
    if (datum.isDouble() && datum.doubleValue() >= -Float.MAX_VALUE && datum.doubleValue() <= Float.MAX_VALUE
        || datum.isLong()
            && datum.longValue() >= (long) -Float.MAX_VALUE
            && datum.longValue() <= (long) Float.MAX_VALUE
        || datum.isFloat()
        || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case DOUBLE:
    if (datum.isDouble() || datum.isFloat() || datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case INT:
    if (datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case LONG:
    if (datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case STRING:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case ENUM:
    if (datum.isTextual() && schema.hasEnumSymbol(datum.textValue())) {
      return MatchType.FULL;
    }
    break;
  case BYTES:
  case FIXED:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case NULL:
    if (datum.isNull()) {
      return MatchType.FULL;
    }
    break;
  default: // unknown
    throw new IllegalArgumentException("Unsupported schema: " + schema);
  }
  return MatchType.NONE;
}
 
开发者ID:HotelsDotCom,项目名称:jasvorno,代码行数:76,代码来源:JasvornoConverter.java

示例14: getLifeEnvironmentVariables

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public ObjectNode getLifeEnvironmentVariables () {

		ObjectNode vars = getAttributeAsObject( ServiceAttributes.environmentVariables );

		if ( vars != null ) {
			JsonNode lifeJson = vars.at( "/lifecycle/" + Application.getCurrentLifeCycle() );
			if ( !lifeJson.isMissingNode() && lifeJson.isObject() ) {
				return (ObjectNode) lifeJson;
			}
		}
		return jacksonMapper.createObjectNode();
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:13,代码来源:ServiceBaseParser.java

示例15: parseArtifact

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private BuckArtifact parseArtifact(Map.Entry<String, JsonNode> entry) {
        String name = entry.getKey();
        JsonNode value = entry.getValue();
        String uri;
        String repo = null;
        if (value.isTextual()) {
            uri = value.asText();
        } else if (value.isObject()) {
            uri = value.get("uri").asText();
            repo = value.get("repo").asText("");
        } else {
            throw new RuntimeException("Unknown element for name: " + name +
                                       " of type: " + value.getNodeType());
        }

        System.out.print(name + " ");
        System.out.flush();
        BuckArtifact buckArtifact;
        if (uri.startsWith("http")) {
            String sha = getHttpSha(uri);
            buckArtifact = BuckArtifact.getArtifact(name, uri, sha);
        } else if (uri.startsWith("mvn")) {
            uri = uri.replaceFirst("mvn:", "");
//            if (repo != null) {
//                System.out.println(name + " " + repo);
//            }
            buckArtifact = AetherResolver.getArtifact(name, uri, repo);
        } else {
            throw new RuntimeException("Unsupported artifact uri: " + uri);
        }
        System.out.println(buckArtifact.url());
        return buckArtifact;
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:BuckLibGenerator.java


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