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


Java JSONObject.isEmpty方法代碼示例

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


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

示例1: getDriversState

import org.json.simple.JSONObject; //導入方法依賴的package包/類
public String getDriversState()
{
    for (JSONObject o : seriesstate.values()) 
    {  // just find any active series and get the drivers table hash from there
        JSONObject hashes = (JSONObject)o.get("hashes");
        if (hashes.isEmpty()) continue;
        return (String)hashes.get("drivers");
    }
    return "";
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:11,代碼來源:MergeServer.java

示例2: getDetail

import org.json.simple.JSONObject; //導入方法依賴的package包/類
public DockerContainerDetail getDetail(DockerContainer container) throws DockerException {
    JSONObject value = (JSONObject) doGetRequest("/containers/" + container.getId() + "/json",
            Collections.singleton(HttpURLConnection.HTTP_OK));
    String name = (String) value.get("Name");
    DockerContainer.Status status = DockerContainer.Status.STOPPED;
    JSONObject state = (JSONObject) value.get("State");
    if (state != null) {
        boolean paused = (Boolean) getOrDefault(state, "Paused", false);
        if (paused) {
            status = DockerContainer.Status.PAUSED;
        } else {
            boolean running = (Boolean) getOrDefault(state, "Running", false);
            if (running) {
                status = DockerContainer.Status.RUNNING;
            }
        }
    }

    boolean tty = false;
    boolean stdin = false;
    JSONObject config = (JSONObject) value.get("Config");
    if (config != null) {
        tty = (boolean) getOrDefault(config, "Tty", false);
        stdin = (boolean) getOrDefault(config, "OpenStdin", false);
    }
    JSONObject ports = (JSONObject) ((JSONObject) value.get("NetworkSettings")).get("Ports");
    if (ports == null || ports.isEmpty()) {
        return new DockerContainerDetail(name, status, stdin, tty);
    } else {
        List<PortMapping> portMapping = new ArrayList<>();
        for (String containerPortData : (Set<String>) ports.keySet()) {
            JSONArray hostPortsArray = (JSONArray) ports.get(containerPortData);
            if (hostPortsArray != null && !hostPortsArray.isEmpty()) {
                Matcher m = PORT_PATTERN.matcher(containerPortData);
                if (m.matches()) {
                    int containerPort = Integer.parseInt(m.group(1));
                    String type = m.group(2).toUpperCase(Locale.ENGLISH);
                    int hostPort = Integer.parseInt((String) ((JSONObject) hostPortsArray.get(0)).get("HostPort"));
                    String hostIp = (String) ((JSONObject) hostPortsArray.get(0)).get("HostIp");
                    portMapping.add(new PortMapping(ExposedPort.Type.valueOf(type), containerPort, hostPort, hostIp));
                } else {
                    LOGGER.log(Level.FINE, "Unparsable port: {0}", containerPortData);
                }
            }
        }
        return new DockerContainerDetail(name, status, stdin, tty, portMapping);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,代碼來源:DockerAction.java

示例3: unconfirmedTransaction

import org.json.simple.JSONObject; //導入方法依賴的package包/類
static JSONObject unconfirmedTransaction(Transaction transaction) {
    JSONObject json = new JSONObject();
    json.put("type", transaction.getType().getType());
    json.put("subtype", transaction.getType().getSubtype());
    json.put("timestamp", transaction.getTimestamp());
    json.put("deadline", transaction.getDeadline());
    json.put("senderPublicKey", Convert.toHexString(transaction.getSenderPublicKey()));
    if (transaction.getRecipientId() != 0) {
        putAccount(json, "recipient", transaction.getRecipientId());
    }
    json.put("amountNQT", String.valueOf(transaction.getAmountNQT()));
    json.put("feeNQT", String.valueOf(transaction.getFeeNQT()));
    if (transaction.getReferencedTransactionFullHash() != null) {
        json.put("referencedTransactionFullHash", transaction.getReferencedTransactionFullHash());
    }
    byte[] signature = Convert.emptyToNull(transaction.getSignature());
    if (signature != null) {
        json.put("signature", Convert.toHexString(signature));
        json.put("signatureHash", Convert.toHexString(Crypto.sha256().digest(signature)));
        json.put("fullHash", transaction.getFullHash());
        json.put("transaction", transaction.getStringId());
    }
    else if (!transaction.getType().isSigned()) {
    	json.put("fullHash", transaction.getFullHash());
        json.put("transaction", transaction.getStringId());
    }
    JSONObject attachmentJSON = new JSONObject();
    for (Appendix appendage : transaction.getAppendages()) {
        attachmentJSON.putAll(appendage.getJSONObject());
    }
    if (! attachmentJSON.isEmpty()) {
        modifyAttachmentJSON(attachmentJSON);
        json.put("attachment", attachmentJSON);
    }
    putAccount(json, "sender", transaction.getSenderId());
    json.put("height", transaction.getHeight());
    json.put("version", transaction.getVersion());
    if (transaction.getVersion() > 0) {
        json.put("ecBlockId", Convert.toUnsignedLong(transaction.getECBlockId()));
        json.put("ecBlockHeight", transaction.getECBlockHeight());
    }

    return json;
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:45,代碼來源:JSONData.java

示例4: collectGatewaysInUseAndInstalledPolicies

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * This function collects all the gateways and servers that exist on the management server
 */
private static void collectGatewaysInUseAndInstalledPolicies(){

    ApiResponse res = null;
    try {
        configuration.getLogger().debug("Run command: 'show-gateways-and-servers' with details level 'full'");
        res = client.apiQuery(loginResponse,"show-gateways-and-servers","objects","{\"details-level\" : \"full\"}");
    }
    catch (ApiClientException e) {
        logoutReportAndExit("Failed to run gateways-and-servers command." + e.getMessage(), MessageType.SEVERE);
    }
    if (res == null || !res.isSuccess()) {
        logoutReportAndExit("Failed to run gateways-and-servers command. " + errorResponseToString(res) , MessageType.SEVERE);
    }
    if(!res.getPayload().containsKey("objects")){
        configuration.getLogger().debug("'objects' key doesn't exist in response from" +
                                                   " 'show-gateways-and-servers' command");
        return;
    }
    JSONArray allGatewaysAndServers = (JSONArray)res.getPayload().get("objects");

    int numberOfObjects = allGatewaysAndServers.size();
    configuration.getLogger().debug("Found " +numberOfObjects+ " gateways from 'show-gateways-and-servers' ");

    //pass over all the gateways and servers
    for (Object gatewayOrServer : allGatewaysAndServers) {
        JSONObject gatewayOrServerJson = (JSONObject) gatewayOrServer;
        //If a policy is installed on the gateway, add this gateway to the list
        if (gatewayOrServerJson.containsKey("policy")) {
            JSONObject policy = (JSONObject) gatewayOrServerJson.get("policy");
            if (!policy.isEmpty()) {
                GatewayAndServer gateway = buildNewGatewayOrServer(gatewayOrServerJson);
                configuration.setGatewaysWithPolicy(gateway);
            }
        }
    }
    int numberOfObjectsWithPolicies = configuration.getGatewaysWithPolicy().size();
    configuration.getLogger().info("Found " +numberOfObjectsWithPolicies +
                                           " gateways that have a policy installed on them");

}
 
開發者ID:CheckPoint-APIs-Team,項目名稱:ShowPolicyPackage,代碼行數:44,代碼來源:ShowPackageTool.java


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