本文整理了Java中org.codehaus.jackson.JsonNode.isArray()
方法的一些代码示例,展示了JsonNode.isArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isArray()
方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:isArray
暂无
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
/**
* Method called to create a new context for iterating all
* contents of the current structured value (JSON array or object)
*/
public final NodeCursor iterateChildren() {
JsonNode n = currentNode();
if (n == null) throw new IllegalStateException("No current node");
if (n.isArray()) { // false since we have already returned START_ARRAY
return new Array(n, this);
}
if (n.isObject()) {
return new Object(n, this);
}
throw new IllegalStateException("Current node of type "+n.getClass().getName());
}
代码示例来源:origin: org.apache.avro/avro
static Set<String> parseAliases(JsonNode node) {
JsonNode aliasesNode = node.get("aliases");
if (aliasesNode == null)
return null;
if (!aliasesNode.isArray())
throw new SchemaParseException("aliases not an array: "+node);
Set<String> aliases = new LinkedHashSet<String>();
for (JsonNode aliasNode : aliasesNode) {
if (!aliasNode.isTextual())
throw new SchemaParseException("alias not a string: "+aliasNode);
aliases.add(aliasNode.getTextValue());
}
return aliases;
}
代码示例来源:origin: org.apache.avro/avro
private void parseTypes(JsonNode json) {
JsonNode defs = json.get("types");
if (defs == null) return; // no types defined
if (!defs.isArray())
throw new SchemaParseException("Types not an array: "+defs);
for (JsonNode type : defs) {
if (!type.isObject())
throw new SchemaParseException("Type not an object: "+type);
Schema.parse(type, types);
}
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
public TreeTraversingParser(JsonNode n, ObjectCodec codec)
{
super(0);
_objectCodec = codec;
if (n.isArray()) {
_nextToken = JsonToken.START_ARRAY;
_nodeCursor = new NodeCursor.Array(n, null);
} else if (n.isObject()) {
_nextToken = JsonToken.START_OBJECT;
_nodeCursor = new NodeCursor.Object(n, null);
} else { // value node
_nodeCursor = new NodeCursor.RootValue(n, null);
}
}
代码示例来源:origin: kaaproject/kaa
/**
* Removes UUIDs from a json tree.
*
* @param json json tree node
*/
public static void removeUuids(JsonNode json) {
boolean containerWithId = json.isContainerNode() && json.has(UUID_FIELD);
boolean isArray = json.isArray();
boolean childIsNotArray = !(json.size() == 1 && json.getElements().next().isArray());
if (containerWithId && !isArray && childIsNotArray) {
((ObjectNode) json).remove(UUID_FIELD);
}
for (JsonNode node : json) {
if (node.isContainerNode()) {
removeUuids(node);
}
}
}
}
代码示例来源:origin: neo4j/neo4j
private static void assertListEquals( String what, List<String> expected, JsonNode jsonNode )
{
assertTrue( what + " - should be a list", jsonNode.isArray() );
List<String> actual = new ArrayList<>( jsonNode.size() );
for ( JsonNode node : jsonNode )
{
actual.add( node.getTextValue() );
}
assertEquals( what, expected, actual );
}
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( HTTP.Response response )
{
try
{
Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();
for ( int metaIndex = 0; meta.hasNext(); metaIndex++ )
{
JsonNode node = meta.next();
if ( metaIndex == index )
{
assertTrue( node.isArray() );
}
}
return true;
}
catch ( JsonParseException e )
{
return false;
}
}
代码示例来源:origin: kaaproject/kaa
/**
* Parses the given string CTL schema along with its dependencies as an
* {@link org.apache.avro.Schema Avro schema}.
*
* @param avroSchema A string CTL schema to parse
* @return A parsed CTL schema as an Avro schema
* @throws Exception - if the given CTL schema is invalid and thus cannot be parsed.
*/
public static Schema parseStringCtlSchema(String avroSchema) throws Exception {
Schema.Parser parser = new Schema.Parser();
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(avroSchema);
JsonNode dependenciesNode = node.get(DEPENDENCIES);
if (dependenciesNode != null && dependenciesNode.isArray()) {
Map<String, Schema> types = new HashMap<>();
for (int i = 0; i < dependenciesNode.size(); i++) {
JsonNode dependencyNode = dependenciesNode.get(i);
Fqn fqn = new Fqn(dependencyNode.get(FQN).asText());
Schema fakeSchema = SchemaBuilder
.record(fqn.getName()).namespace(fqn.getNamespace())
.fields()
.endRecord();
types.put(fqn.getFqnString(), fakeSchema);
}
parser.addTypes(types);
}
return parser.parse(avroSchema);
}
代码示例来源:origin: azkaban/azkaban
} else if (node.isArray()) {
final ArrayList<Object> array = new ArrayList<>();
final Iterator<JsonNode> iter = node.getElements();
代码示例来源:origin: org.apache.avro/avro
return defaultValue.isNull();
case ARRAY:
if (!defaultValue.isArray())
return false;
for (JsonNode element : defaultValue)
代码示例来源:origin: org.apache.avro/avro
} else if (jsonNode.isArray()) {
List l = new ArrayList();
for (JsonNode node : jsonNode) {
代码示例来源:origin: neo4j/neo4j
assertTrue( "data is a list", data.isArray() );
assertEquals( "one entry", initialData + 1, data.size() );
JsonNode entry = data.get( 0 );
JsonNode nodes = entry.get( "graph" ).get( "nodes" );
JsonNode rels = entry.get( "graph" ).get( "relationships" );
assertTrue( "nodes is a list", nodes.isArray() );
assertTrue( "relationships is a list", rels.isArray() );
assertEquals( "one node", 1, nodes.size() );
assertEquals( "no relationships", 0, rels.size() );
代码示例来源:origin: kaaproject/kaa
if (!object.has(DEPENDENCIES)) {
schema.setDependencySet(dependencies);
} else if (!object.get(DEPENDENCIES).isArray()) {
throw new IllegalArgumentException("Illegal dependencies format!");
} else {
代码示例来源:origin: apache/hive
@Test
public void testJsonEmptyRPFormatter() throws Exception {
WMFullResourcePlan fullRp = createRP("test_rp_1", null, null);
formatter.showFullResourcePlan(out, fullRp);
out.flush();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonTree = objectMapper.readTree(bos.toByteArray());
assertNotNull(jsonTree);
assertTrue(jsonTree.isObject());
assertEquals("test_rp_1", jsonTree.get("name").asText());
assertTrue(jsonTree.get("parallelism").isNull());
assertTrue(jsonTree.get("defaultPool").isNull());
assertTrue(jsonTree.get("pools").isArray());
assertEquals(0, jsonTree.get("pools").size());
}
代码示例来源:origin: apache/nifi
if (fieldNode.isArray()) {
final ArrayNode arrayNode = (ArrayNode) fieldNode;
final int numElements = arrayNode.size();
代码示例来源:origin: neo4j/neo4j
assertTrue( "Expected to find a JSON node, but there was none", meta.hasNext() );
JsonNode node = meta.next();
assertTrue( "Expected the node to be a list (for a path)", node.isArray() );
for ( JsonNode inner : node )
代码示例来源:origin: apache/nifi
if (fieldNode.isArray()) {
final ArrayNode arrayNode = (ArrayNode) fieldNode;
final int numElements = arrayNode.size();
代码示例来源:origin: apache/hive
assertEquals(10, jsonTree.get("parallelism").asInt());
assertEquals("def", jsonTree.get("defaultPool").asText());
assertTrue(jsonTree.get("pools").isArray());
assertEquals(2, jsonTree.get("pools").size());
assertEquals(7, pool2.get("parallelism").asInt());
assertEquals(0.7, pool2.get("allocFraction").asDouble(), 0.00001);
assertTrue(pool2.get("triggers").isArray());
assertEquals(0, pool2.get("triggers").size());
assertTrue(pool2.get("mappings").isArray());
JsonNode type0 = pool2.get("mappings").get(0);
assertEquals("user", type0.get("type").asText());
assertTrue(type0.get("values").isArray());
assertEquals(2, type0.get("values").size());
HashSet<String> vals = new HashSet<>();
assertEquals(3, pool1.get("parallelism").asInt());
assertEquals(0.3, pool1.get("allocFraction").asDouble(), 0.00001);
assertTrue(pool1.get("triggers").isArray());
assertEquals(1, pool1.get("triggers").size());
代码示例来源:origin: neo4j/neo4j
JsonNode errors = result.get(0).get("body").get("errors");
assertTrue( "Results not an array", results.isArray() );
assertEquals( 0, results.size() );
assertTrue( "Errors not an array", errors.isArray() );
assertEquals( 1, errors.size() );
代码示例来源:origin: kaaproject/kaa
if (byDefault.isArray() && AvroUtils.getSchemaByType(schemaNode, Type.BYTES) != null) {
内容来源于网络,如有侵权,请联系作者删除!