本文整理了Java中org.codehaus.jackson.JsonNode.isObject()
方法的一些代码示例,展示了JsonNode.isObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isObject()
方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:isObject
暂无
代码示例来源: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: apache/incubator-gobblin
/**
* Instantiate a new keystore using the file at the provided path
*/
public JsonCredentialStore(Path path, KeyToStringCodec codec) throws IOException {
credentials = new HashMap<>();
FileSystem fs = path.getFileSystem(new Configuration());
try (InputStream in = fs.open(path)) {
ObjectMapper jsonParser = defaultMapper;
JsonNode tree = jsonParser.readTree(in);
if (!tree.isObject()) {
throw new IllegalArgumentException("Json in " + path.toString() + " is not an object!");
}
Iterator<Map.Entry<String, JsonNode>> it = tree.getFields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> field = it.next();
String keyId = field.getKey();
byte[] key = codec.decodeKey(field.getValue().getTextValue());
credentials.put(keyId, key);
}
}
log.info("Initialized keystore from {} with {} keys", path.toString(), credentials.size());
}
代码示例来源:origin: neo4j/neo4j
private JsonNode assertIsPlanRoot( String result ) throws JsonParseException
{
JsonNode json = jsonNode( result );
JsonNode results = json.get( "results" ).get( 0 );
JsonNode plan = results.get( "plan" );
assertTrue( "Expected plan to be an object", plan != null && plan.isObject() );
JsonNode root = plan.get("root");
assertTrue("Expected plan to be an object", root != null && root.isObject());
return root;
}
代码示例来源: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: azkaban/azkaban
private static Object toObjectFromJSONNode(final JsonNode node) {
if (node.isObject()) {
final HashMap<String, Object> obj = new HashMap<>();
final Iterator<String> iter = node.getFieldNames();
代码示例来源:origin: org.apache.avro/avro
return true;
case MAP:
if (!defaultValue.isObject())
return false;
for (JsonNode value : defaultValue)
return isValidDefault(schema.getTypes().get(0), defaultValue);
case RECORD:
if (!defaultValue.isObject())
return false;
for (Field field : schema.getFields())
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testToJson() throws IOException {
GlobalMetadata m = new GlobalMetadata();
m.addTransferEncoding("foo");
m.addTransferEncoding("bar");
byte[] utf8 = m.toJsonUtf8();
String parsed = new String(utf8, StandardCharsets.UTF_8);
JsonNode root = new ObjectMapper().readTree(parsed);
Assert.assertTrue(root.isObject());
Iterator<JsonNode> children = root.getElements();
int numChildren = 0;
while (children.hasNext()) {
children.next();
numChildren++;
}
Assert.assertEquals(numChildren, 3, "expected only 3 child nodes - file, dataset, id");
Assert.assertEquals(root.get("file").size(), 0, "expected no children in file node");
Assert.assertTrue(root.get("id").isTextual(), "expected ID to be textual");
JsonNode transferEncoding = root.get("dataset").get("Transfer-Encoding");
Assert.assertEquals(transferEncoding.size(), m.getTransferEncoding().size());
for (int i = 0; i < m.getTransferEncoding().size(); i++) {
Assert.assertEquals(transferEncoding.get(i).getTextValue(), m.getTransferEncoding().get(i));
}
}
代码示例来源:origin: org.apache.avro/avro
} else if (jsonNode.isObject()) {
Map m = new LinkedHashMap();
for (Iterator<String> it = jsonNode.getFieldNames(); it.hasNext(); ) {
代码示例来源:origin: apache/nifi
if (fieldNode.isObject()) {
RecordSchema childSchema;
if (desiredType instanceof RecordDataType) {
代码示例来源:origin: apache/nifi
if (fieldNode.isObject()) {
RecordSchema childSchema;
if (desiredType instanceof RecordDataType) {
代码示例来源:origin: kaaproject/kaa
} else {
for (JsonNode child : object.get(DEPENDENCIES)) {
if (!child.isObject() || !child.has(FQN) || !child.get(FQN).isTextual()
|| !child.has(VERSION) || !child.get(VERSION).isInt()) {
throw new IllegalArgumentException("Illegal dependency format!");
代码示例来源:origin: voldemort/voldemort
break;
case MAP:
if(defaultJson.isObject()) {
boolean isGood = true;
for(JsonNode node: defaultJson) {
break;
case RECORD:
if(defaultJson.isObject()) {
boolean isGood = true;
for(Field field: schema.getFields()) {
代码示例来源: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.isObject()) {
RecordSchema childSchema = null;
if (dataType != null && RecordFieldType.RECORD == dataType.getFieldType()) {
代码示例来源:origin: apache/nifi
if (fieldNode.isObject()) {
RecordSchema childSchema;
if (dataType != null && RecordFieldType.RECORD == dataType.getFieldType()) {
代码示例来源:origin: org.apache.avro/avro
throw new SchemaParseException("Undefined name: "+schema);
return result;
} else if (schema.isObject()) {
Schema result;
String type = getRequiredText(schema, "type", "No type");
代码示例来源:origin: neo4j/neo4j
for ( JsonNode child : root.get( "children" ) )
assertTrue( "Expected object", child.isObject() );
assertEquals( "child", child.get( "operatorType" ).getTextValue() );
identifiers.add( identifiersOf( child ) );
代码示例来源:origin: apache/hive
assertTrue(jsonTree.isObject());
assertEquals("test_rp_2", jsonTree.get("name").asText());
assertEquals(10, jsonTree.get("parallelism").asInt());
代码示例来源:origin: camunda/camunda-bpm-platform
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!