当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.putAll方法代码示例

本文整理汇总了Java中org.json.simple.JSONObject.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.putAll方法的具体用法?Java JSONObject.putAll怎么用?Java JSONObject.putAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.simple.JSONObject的用法示例。


在下文中一共展示了JSONObject.putAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeJson

import org.json.simple.JSONObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void writeJson(HttpServletResponse response, Map<String, Object> sessionParams) throws ServletException {
	try {
		JSONObject json = new JSONObject();
		json.putAll(sessionParams);
		response.setContentType("application/json");
		response.setHeader("Cache-Control", "no-cache");

		if (log.isTraceEnabled()) {
			log.trace("Responding with: " + json.toJSONString());
		}

		response.getWriter().write(json.toJSONString());
	} catch (IOException e) {
		throw new ServletException("Could not create json.", e);
	}
}
 
开发者ID:nortal,项目名称:cas-modules,代码行数:18,代码来源:MobileIdController.java

示例2: createResponse

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * boxインストールが実行されていないか、実行されたがキャッシュの有効期限が切れた場合のレスポンスを作成する.
 * @return レスポンス用JSONオブジェクト
 */
@SuppressWarnings("unchecked")
private JSONObject createResponse(JSONObject values) {
    JSONObject response = new JSONObject();
    response.putAll(values);
    response.remove("cell_id");
    response.remove("box_id");
    response.put("schema", this.getBox().getSchema());
    ProgressInfo.STATUS status = ProgressInfo.STATUS.valueOf((String) values.get("status"));
    if (status == ProgressInfo.STATUS.COMPLETED) {
        response.remove("progress");
        String startedAt = (String) response.remove("started_at");
        response.put("installed_at", startedAt);
    }
    response.put("status", status.value());
    return response;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:BoxResource.java

示例3: getJSONObject

import org.json.simple.JSONObject; //导入方法依赖的package包/类
@Override
public JSONObject getJSONObject() {
    JSONObject json = new JSONObject();
    json.put("type", type.getType());
    json.put("subtype", type.getSubtype());
    json.put("timestamp", timestamp);
    json.put("deadline", deadline);
    json.put("senderPublicKey", Convert.toHexString(senderPublicKey));
    if (type.hasRecipient()) {
        json.put("recipient", Convert.toUnsignedLong(recipientId));
    }
    json.put("amountNQT", amountNQT);
    json.put("feeNQT", feeNQT);
    if (referencedTransactionFullHash != null) {
        json.put("referencedTransactionFullHash", referencedTransactionFullHash);
    }
    json.put("ecBlockHeight", ecBlockHeight);
    json.put("ecBlockId", Convert.toUnsignedLong(ecBlockId));
    json.put("signature", Convert.toHexString(signature));
    JSONObject attachmentJSON = new JSONObject();
    for (Appendix appendage : appendages) {
        attachmentJSON.putAll(appendage.getJSONObject());
    }
    //if (! attachmentJSON.isEmpty()) {
        json.put("attachment", attachmentJSON);
    //}
    json.put("version", version);
    return json;
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:30,代码来源:TransactionImpl.java

示例4: 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


注:本文中的org.json.simple.JSONObject.putAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。