當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.has方法代碼示例

本文整理匯總了Java中org.codehaus.jettison.json.JSONObject.has方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.has方法的具體用法?Java JSONObject.has怎麽用?Java JSONObject.has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.jettison.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.has方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: exportUsers

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public JSONObject exportUsers(JSONArray usernames) throws EngineException {
	try {
		JSONObject users;
		JSONObject export = new JSONObject();
		
		synchronized (this) {
			users = load();
		}

		for (int i = 0; i < usernames.length(); i++) {
			String name = usernames.getJSONObject(i).getString("name");
			if (users.has(name)) {
				export.put(name, users.get(name));
			}
		}
		return export;
	} catch (Exception exception) {
		throw new EngineException("Failed to update Users", exception);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:21,代碼來源:AuthenticatedSessionManager.java

示例2: addSequences

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
private void addSequences(Map<String, Set<String>> map, TVObject tvs, Object object, boolean isReferenced) {
	if (object != null) {
		if (object instanceof Project) {
			Project project = (Project)object;
			for (Sequence s : project.getSequencesList()) {
				String label = isReferenced ? s.getQName():s.getName();

				tvs.add(new TVObject(label, s));
				
				Set<String> infos = map.get(s.getQName());
				if (infos != null) {
					for (String info: infos) {
						try {
							JSONObject jsonInfo = new JSONObject(info);
							if (jsonInfo.has("marker")) {
								String marker = jsonInfo.getString("marker");
								if (!marker.isEmpty()) {
									tvs.add(new TVObject(label + "#" + marker, s, jsonInfo));
								}
							}
						} catch (JSONException e) {
							e.printStackTrace();
						}
					}
				}
			}
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:30,代碼來源:MobilePickerContentProvider.java

示例3: hasUser

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public boolean hasUser(String username) throws EngineException {
	try {
		JSONObject db;
		synchronized (this) {
			db = load();
		}
		return db.has(username);
	} catch (Exception e) {
		return false;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:12,代碼來源:AuthenticatedSessionManager.java

示例4: IonProperty

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public IonProperty(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonProperty.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:13,代碼來源:IonProperty.java

示例5: IonEvent

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public IonEvent(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonEvent.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:13,代碼來源:IonEvent.java

示例6: IonBean

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public IonBean(String jsonString) throws JSONException {
	this();
	JSONObject jsonOb = new JSONObject(jsonString);
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonBean.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:14,代碼來源:IonBean.java

示例7: IonConfig

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public IonConfig(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonConfig.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:13,代碼來源:IonConfig.java

示例8: invoke

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
@Override
protected JSONObject invoke() throws Exception {
	JSONObject response = super.invoke();
	if ((response.has("ok") && response.getBoolean("ok"))
		|| response.has("error") && "not_found".equals(response.getString("error"))) {
		CouchDbManager.syncDocument(getConnector());
		if (response.has("error")) {
			response.remove("error");
			response.remove("reason");
			response.put("ok", true);
		}
	}
	return response;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:15,代碼來源:ResetDatabaseTransaction.java

示例9: getDelegationTokenFromJson

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public static DelegationToken getDelegationTokenFromJson(JSONObject json)
    throws JSONException {
  DelegationToken ret = new DelegationToken();
  if (json.has("token")) {
    ret.setToken(json.getString("token"));
  } else if (json.has("expiration-time")) {
    ret.setNextExpirationTime(json.getLong("expiration-time"));
  }
  return ret;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:11,代碼來源:TestRMWebServicesDelegationTokens.java

示例10: verifyHsJob

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public static void verifyHsJob(JSONObject info, Job job) throws JSONException {
  assertEquals("incorrect number of elements", 25, info.length());

  // everyone access fields
  verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
      info.getString("name"), info.getString("state"),
      info.getString("queue"), info.getLong("startTime"),
      info.getLong("finishTime"), info.getInt("mapsTotal"),
      info.getInt("mapsCompleted"), info.getInt("reducesTotal"),
      info.getInt("reducesCompleted"));

  String diagnostics = "";
  if (info.has("diagnostics")) {
    diagnostics = info.getString("diagnostics");
  }

  // restricted access fields - if security and acls set
  verifyHsJobGenericSecure(job, info.getBoolean("uberized"), diagnostics,
      info.getLong("avgMapTime"), info.getLong("avgReduceTime"),
      info.getLong("avgShuffleTime"), info.getLong("avgMergeTime"),
      info.getInt("failedReduceAttempts"),
      info.getInt("killedReduceAttempts"),
      info.getInt("successfulReduceAttempts"),
      info.getInt("failedMapAttempts"), info.getInt("killedMapAttempts"),
      info.getInt("successfulMapAttempts"));

  // acls not being checked since
  // we are using mock job instead of CompletedJob
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:VerifyJobsUtils.java

示例11: collectComponentTypes

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
private static void collectComponentTypes(JSONObject componentProperties,
    Set<String> componentTypes) throws JSONException {
  String componentType = componentProperties.getString("$Type");
  componentTypes.add(componentType);

  // Recursive call to collect nested components.
  if (componentProperties.has("$Components")) {
    JSONArray components = componentProperties.getJSONArray("$Components");
    for (int i = 0; i < components.length(); i++) {
      collectComponentTypes(components.getJSONObject(i), componentTypes);
    }
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:14,代碼來源:FormPropertiesAnalyzer.java

示例12: getExecutorId

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
private String getExecutorId(final JSONObject executor) throws JSONException {
    return executor.has("id") ? executor.getString("id") : executor.getString("executor_id");
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:4,代碼來源:MesosStateService.java

示例13: verifySubQueue

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
private void verifySubQueue(JSONObject info, String q, 
    float parentAbsCapacity, float parentAbsMaxCapacity)
    throws JSONException, Exception {
  int numExpectedElements = 13;
  boolean isParentQueue = true;
  if (!info.has("queues")) {
    numExpectedElements = 25;
    isParentQueue = false;
  }
  assertEquals("incorrect number of elements", numExpectedElements, info.length());

  QueueInfo qi = isParentQueue ? new QueueInfo() : new LeafQueueInfo();
  qi.capacity = (float) info.getDouble("capacity");
  qi.usedCapacity = (float) info.getDouble("usedCapacity");
  qi.maxCapacity = (float) info.getDouble("maxCapacity");
  qi.absoluteCapacity = (float) info.getDouble("absoluteCapacity");
  qi.absoluteMaxCapacity = (float) info.getDouble("absoluteMaxCapacity");
  qi.absoluteUsedCapacity = (float) info.getDouble("absoluteUsedCapacity");
  qi.numApplications = info.getInt("numApplications");
  qi.queueName = info.getString("queueName");
  qi.state = info.getString("state");

  verifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);

  if (isParentQueue) {
    JSONArray arr = info.getJSONObject("queues").getJSONArray("queue");
    // test subqueues
    for (int i = 0; i < arr.length(); i++) {
      JSONObject obj = arr.getJSONObject(i);
      String q2 = q + "." + obj.getString("queueName");
      verifySubQueue(obj, q2, qi.absoluteCapacity, qi.absoluteMaxCapacity);
    }
  } else {
    LeafQueueInfo lqi = (LeafQueueInfo) qi;
    lqi.numActiveApplications = info.getInt("numActiveApplications");
    lqi.numPendingApplications = info.getInt("numPendingApplications");
    lqi.numContainers = info.getInt("numContainers");
    lqi.maxApplications = info.getInt("maxApplications");
    lqi.maxApplicationsPerUser = info.getInt("maxApplicationsPerUser");
    lqi.userLimit = info.getInt("userLimit");
    lqi.userLimitFactor = (float) info.getDouble("userLimitFactor");
    verifyLeafQueueGeneric(q, lqi);
    // resourcesUsed and users (per-user resources used) are checked in
    // testPerUserResource()
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:47,代碼來源:TestRMWebServicesCapacitySched.java

示例14: verifyAMJob

import org.codehaus.jettison.json.JSONObject; //導入方法依賴的package包/類
public void verifyAMJob(JSONObject info, Job job) throws JSONException {

    assertEquals("incorrect number of elements", 30, info.length());

    // everyone access fields
    verifyAMJobGeneric(job, info.getString("id"), info.getString("user"),
        info.getString("name"), info.getString("state"),
        info.getLong("startTime"), info.getLong("finishTime"),
        info.getLong("elapsedTime"), info.getInt("mapsTotal"),
        info.getInt("mapsCompleted"), info.getInt("reducesTotal"),
        info.getInt("reducesCompleted"),
        (float) info.getDouble("reduceProgress"),
        (float) info.getDouble("mapProgress"));

    String diagnostics = "";
    if (info.has("diagnostics")) {
      diagnostics = info.getString("diagnostics");
    }

    // restricted access fields - if security and acls set
    verifyAMJobGenericSecure(job, info.getInt("mapsPending"),
        info.getInt("mapsRunning"), info.getInt("reducesPending"),
        info.getInt("reducesRunning"), info.getBoolean("uberized"),
        diagnostics, info.getInt("newReduceAttempts"),
        info.getInt("runningReduceAttempts"),
        info.getInt("failedReduceAttempts"),
        info.getInt("killedReduceAttempts"),
        info.getInt("successfulReduceAttempts"), info.getInt("newMapAttempts"),
        info.getInt("runningMapAttempts"), info.getInt("failedMapAttempts"),
        info.getInt("killedMapAttempts"), info.getInt("successfulMapAttempts"));

    Map<JobACL, AccessControlList> allacls = job.getJobACLs();
    if (allacls != null) {

      for (Map.Entry<JobACL, AccessControlList> entry : allacls.entrySet()) {
        String expectName = entry.getKey().getAclName();
        String expectValue = entry.getValue().getAclString();
        Boolean found = false;
        // make sure ws includes it
        if (info.has("acls")) {
          JSONArray arr = info.getJSONArray("acls");

          for (int i = 0; i < arr.length(); i++) {
            JSONObject aclInfo = arr.getJSONObject(i);
            if (expectName.matches(aclInfo.getString("name"))) {
              found = true;
              WebServicesTestUtils.checkStringMatch("value", expectValue,
                  aclInfo.getString("value"));
            }
          }
        } else {
          fail("should have acls in the web service info");
        }
        assertTrue("acl: " + expectName + " not found in webservice output",
            found);
      }
    }

  }
 
開發者ID:naver,項目名稱:hadoop,代碼行數:60,代碼來源:TestAMWebServicesJobs.java


注:本文中的org.codehaus.jettison.json.JSONObject.has方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。