本文整理了Java中org.codehaus.jettison.json.JSONObject.getJSONObject()
方法的一些代码示例,展示了JSONObject.getJSONObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getJSONObject()
方法的具体详情如下:
包路径:org.codehaus.jettison.json.JSONObject
类名称:JSONObject
方法名:getJSONObject
[英]Get the JSONObject value associated with a key.
[中]获取与键关联的JSONObject值。
代码示例来源:origin: apache/nifi
if (jobState.equalsIgnoreCase("available")) {
log.debug("submitAndHandleJob() Job status is: " + jobState + ". returning output...");
output = jobInfo.getJSONObject("output");
} else if (jobState.equalsIgnoreCase("running") || jobState.equalsIgnoreCase("waiting")) {
while (!jobState.equalsIgnoreCase("available")) {
jobState = jobInfo.getString("state");
output = jobInfo.getJSONObject("output");
} else if (jobState.equalsIgnoreCase("error")
|| jobState.equalsIgnoreCase("cancelled")
代码示例来源:origin: apache/nifi
} else {
try {
final JSONObject output = result.getJSONObject("data");
flowFile = session.write(flowFile, out -> out.write(output.toString().getBytes()));
flowFile = session.putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(), LivySessionService.APPLICATION_JSON);
代码示例来源:origin: org.codehaus.jettison/jettison
public BadgerFishXMLStreamReader(JSONObject obj)
throws JSONException, XMLStreamException {
String rootName = (String) obj.keys().next();
this.node = new Node(null, rootName, obj.getJSONObject(rootName), CONVENTION);
this.nodes = new FastStack();
nodes.push(node);
event = START_DOCUMENT;
}
代码示例来源:origin: eBay/parallec
hasMore = jsonObjectNext.getBoolean(KEY_HAS_MORE);
if (jsonObjectNext.has(KEY_NEXT_PARENT)
&& jsonObjectNext.getJSONObject(KEY_NEXT_PARENT)
.has(KEY_NEXT_URL)) {
hasMoreNextUrl = jsonObjectNext.getJSONObject(
KEY_NEXT_PARENT).getString(KEY_NEXT_URL);
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
@Nullable
public static JSONObject getNestedOptionalObject(JSONObject json, final String... path) throws JSONException {
for (int i = 0; i < path.length - 1; i++) {
String s = path[i];
json = json.getJSONObject(s);
}
return json.optJSONObject(path[path.length - 1]);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
@Nullable
public static JSONObject getNestedOptionalObject(JSONObject json, String... path) throws JSONException {
for (int i = 0; i < path.length - 1; i++) {
String s = path[i];
json = json.getJSONObject(s);
}
return json.optJSONObject(path[path.length - 1]);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
private Collection<Field> parseFields(JSONObject json) throws JSONException {
ArrayList<Field> res = new ArrayList<Field>(json.length());
final Iterator<String> iterator = getStringKeys(json);
while (iterator.hasNext()) {
final String key = iterator.next();
if (SPECIAL_FIELDS.contains(key)) {
continue;
}
res.add(fieldParser.parse(json.getJSONObject(key), key));
}
return res;
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
private String getFieldStringUnisex(final JSONObject json, final String attributeName) throws JSONException {
final JSONObject fieldsJson = json.getJSONObject(FIELDS);
final Object fieldJson = fieldsJson.get(attributeName);
if (fieldJson instanceof JSONObject) {
return ((JSONObject) fieldJson).getString(VALUE_ATTR); // pre 5.0 way
}
return fieldJson.toString(); // JIRA 5.0 way
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
@Override
public Map<String, CimFieldInfo> parse(JSONObject json) throws JSONException {
final Map<String, CimFieldInfo> res = Maps.newHashMapWithExpectedSize(json.length());
final Iterator keysIterator = json.keys();
while (keysIterator.hasNext()) {
final String id = (String) keysIterator.next();
res.put(id, parseIssueFieldInfo(json.getJSONObject(id), id));
}
return res;
}
代码示例来源:origin: opensourceBIM/BIMserver
sServiceDescriptor.setAuthorizeUrl(service.getString("authorizeUrl"));
JSONObject rights = service.getJSONObject("rights");
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
private String getFieldStringValue(final JSONObject json, final String attributeName) throws JSONException {
final JSONObject fieldsJson = json.getJSONObject(FIELDS);
final Object summaryObject = fieldsJson.get(attributeName);
if (summaryObject instanceof JSONObject) { // pre JIRA 5.0 way
return ((JSONObject) summaryObject).getString(VALUE_ATTR);
}
if (summaryObject instanceof String) { // JIRA 5.0 way
return (String) summaryObject;
}
throw new JSONException("Cannot parse [" + attributeName + "] from available fields");
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
private String getFieldStringValue(JSONObject json, String attributeName) throws JSONException {
final JSONObject fieldsJson = json.getJSONObject(FIELDS);
final Object summaryObject = fieldsJson.get(attributeName);
if (summaryObject instanceof JSONObject) { // pre JIRA 5.0 way
return ((JSONObject) summaryObject).getString(VALUE_ATTR);
}
if (summaryObject instanceof String) { // JIRA 5.0 way
return (String) summaryObject;
}
throw new JSONException("Cannot parse [" + attributeName + "] from available fields");
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
@Override
public Session parse(JSONObject json) throws JSONException {
final URI userUri = JsonParseUtil.getSelfUri(json);
final String username = json.getString("name");
final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo"));
return new Session(userUri, username, loginInfo);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
private void verifyQueueOrder(JSONObject json, String realOrder)
throws Exception {
String order = "";
if (!json.isNull("root")) {
JSONObject root = json.getJSONObject("root");
order = root.getString("name") + "-" + getQueueOrder(root);
}
assertEquals("Order of queue is wrong",
order.substring(0, order.length() - 1), realOrder);
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
private void verifyNumberOfNodes(JSONObject allocation, int realValue)
throws Exception {
if (allocation.isNull("root")) {
assertEquals("State of allocation is wrong", 0, realValue);
} else {
assertEquals("State of allocation is wrong",
1 + getNumberOfNodes(allocation.getJSONObject("root")), realValue);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
private JSONObject getSubQueue(JSONObject queue, String subQueue)
throws JSONException {
JSONArray queues = queue.getJSONObject("queues").getJSONArray("queue");
for (int i=0; i<queues.length(); ++i) {
checkResourcesUsed(queues.getJSONObject(i));
if (queues.getJSONObject(i).getString("queueName").equals(subQueue) ) {
return queues.getJSONObject(i);
}
}
return null;
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
private void verifyReservationCount(int count) throws Exception {
WebResource resource = constructWebResource(LIST_RESERVATION_PATH)
.queryParam("queue", DEFAULT_QUEUE);
JSONObject json = testListReservationHelper(resource);
if (count == 1) {
// If there are any number other than one reservation, this will throw.
json.getJSONObject("reservations");
} else {
JSONArray reservations = json.getJSONArray("reservations");
assertTrue(reservations.length() == count);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app
@Test
public void testAM() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("mapreduce")
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app
@Test
public void testInfoDefault() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("mapreduce")
.path("info/").get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager
public void testSingleNodeHelper(String nodeid, RMNode nm, String media)
throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster")
.path("nodes").path(nodeid).accept(media).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("node");
verifyNodeInfo(info, nm);
}
内容来源于网络,如有侵权,请联系作者删除!