当前位置: 首页>>代码示例>>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;未经允许,请勿转载。