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


Java JSONObject.remove方法代碼示例

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


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

示例1: modifyAttachmentJSON

import org.json.simple.JSONObject; //導入方法依賴的package包/類
private static void modifyAttachmentJSON(JSONObject json) {
    Long quantityQNT = (Long) json.remove("quantityQNT");
    if (quantityQNT != null) {
        json.put("quantityQNT", String.valueOf(quantityQNT));
    }
    Long priceNQT = (Long) json.remove("priceNQT");
    if (priceNQT != null) {
        json.put("priceNQT", String.valueOf(priceNQT));
    }
    Long discountNQT = (Long) json.remove("discountNQT");
    if (discountNQT != null) {
        json.put("discountNQT", String.valueOf(discountNQT));
    }
    Long refundNQT = (Long) json.remove("refundNQT");
    if (refundNQT != null) {
        json.put("refundNQT", String.valueOf(refundNQT));
    }
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:19,代碼來源:JSONData.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: showThreatExceptionRulebase

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 *This function returns all the threat exception rules of a given rule and given threat layer .
 *
 * @param threatLayer the threat layer of the threat rule
 * @param ruleUid the rule uid of the rule containing the exception rules
 *
 * @return the exception rules, or null in case of fail.
 */
private static JSONObject showThreatExceptionRulebase(Layer threatLayer, String ruleUid) {

    ApiResponse res;
    //Creating the payload
    JSONObject payload = new JSONObject();
    payload.put("rule-uid", ruleUid);
    payload.put("details-level", "full");
    payload.put("use-object-dictionary",true);
    payload.put("uid", threatLayer.getUid());

    try {
        configuration.getLogger().debug("Run command: 'show-threat-rule-exception-rulebase' " +
                                                   "for threat layer: '" + threatLayer.getName() + "' ('" + ruleUid
                                                + "') with details level 'full'");

        res = client.apiCall(loginResponse,"show-threat-rule-exception-rulebase", payload);
    }
    catch (ApiClientException e) {
        // probably due to a version that does not support threatLayerUid and supports only layerName
        payload.remove("uid");
        payload.put("name", threatLayer.getName());

        try {
            res = client.apiCall(loginResponse,"show-threat-rule-exception-rulebase", payload);
        }
        catch (ApiClientException e1) {
            handleException(e1,"Failed to run show-threat-rule-exception-rulebase command ("
                                                     + threatLayer.getName() + "'" + threatLayer.getUid() + "')");
            return null;
        }
    }
    if (res == null || !res.isSuccess()) {
        configuration.getLogger().severe("Failed to run show-threat-rule-exception-rulebase command ('"
                                                 + threatLayer.getName() + "' uid: '" + threatLayer.getUid() + "'). " +
                                                 errorResponseToString(res));
        return null;
    }
    return res.getPayload();
}
 
開發者ID:CheckPoint-APIs-Team,項目名稱:ShowPolicyPackage,代碼行數:48,代碼來源:ShowPackageTool.java

示例4: setSubjectPath

import org.json.simple.JSONObject; //導入方法依賴的package包/類
protected static void setSubjectPath(String subject, String path){
	
	boolean portable=ClassicRoutines.isPortable();
	
	// If subject folders key doesn't exist, it is created
	if(!jsonConf.containsKey("SubjectFolders")) jsonConf.put("SubjectFolders", new JSONObject());					// Not portable
	if(!jsonConf.containsKey("RelativeSubjectFolders")) jsonConf.put("RelativeSubjectFolders", new JSONObject());	// Portable
	
	JSONObject jsonfoldersabs=(JSONObject) jsonConf.get("SubjectFolders");
	JSONObject jsonfoldersrel=(JSONObject) jsonConf.get("RelativeSubjectFolders");
	
	String subjectUniqueName=getSubjectUniqueName(subject);
	
	// If the subject folder is registered, it is deleted so as to add it again
	if(jsonfoldersabs.containsKey(subjectUniqueName)) jsonfoldersabs.remove(subjectUniqueName);
	if(jsonfoldersrel.containsKey(subjectUniqueName)) jsonfoldersrel.remove(subjectUniqueName);
	
	String relpath=ClassicRoutines.getRelativePath(path, ClassicRoutines.getJarPathFolder());
	
	if(path.equals(relpath) || !portable){
		// Save it as absolute if equal or not portable
		jsonfoldersabs.put(subjectUniqueName, path);
	} else{
		// Save it as relative
		jsonfoldersrel.put(subjectUniqueName,relpath);
		
	}
	
	// Update the SubjectFolders section
	if(jsonConf.containsKey("SubjectFolders")) jsonConf.remove("SubjectFolders");
	jsonConf.put("SubjectFolders", jsonfoldersabs);
	if(jsonConf.containsKey("RelativeSubjectFolders")) jsonConf.remove("RelativeSubjectFolders");
	jsonConf.put("RelativeSubjectFolders", jsonfoldersrel);
	
	
}
 
開發者ID:davovoid,項目名稱:faitic-checker,代碼行數:37,代碼來源:Settings.java

示例5: getActivitySummary

import org.json.simple.JSONObject; //導入方法依賴的package包/類
public static Map<String, Object> getActivitySummary(JSONObject activitySummary, String activityType)
{
	Map<String, Object> summary = new HashMap<String, Object>();

	if(activityType.equals("org.alfresco.documentlibrary.file-added"))
	{
		String nodeRefStr = (String)activitySummary.remove("nodeRef");
		if(NodeRef.isNodeRef(nodeRefStr))
		{
			summary.put("objectId", new NodeRef(nodeRefStr).getId());
		}
		else
		{
			throw new RuntimeException("nodeRef " + nodeRefStr + " in activity feed is not a valid NodeRef");
		}
		String parentNodeRefStr = (String)activitySummary.remove("parentNodeRef");
		if(NodeRef.isNodeRef(parentNodeRefStr))
		{
			summary.put("parentObjectId", new NodeRef(parentNodeRefStr).getId());
		}
		else
		{
			throw new RuntimeException("parentNodeRef " + parentNodeRefStr + " in activity feed is not a valid NodeRef");
		}
		summary.put("lastName", activitySummary.get("lastName"));
		summary.put("firstName", activitySummary.get("firstName"));
		summary.put("title", activitySummary.get("title"));
	} else if(activityType.equals("org.alfresco.site.user-joined"))
	{
		summary.put("lastName", activitySummary.get("lastName"));
		summary.put("firstName", activitySummary.get("firstName"));
		summary.put("memberLastName", activitySummary.get("memberLastName"));
		summary.put("memberFirstName", activitySummary.get("memberFirstName"));
		summary.put("memberPersonId", activitySummary.get("memberUserName"));
		summary.put("role", activitySummary.get("role"));
		summary.put("title", activitySummary.get("title"));
	}

	return summary;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:41,代碼來源:Activity.java

示例6: TestEventResource

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * リクエストボディのlevelがない場合に場合にエラーとなること.
 */
@Test(expected = PersoniumCoreException.class)
public void リクエストボディのlevelがない場合にエラーとなること() {
    TestEventResource resource = new TestEventResource();
    JSONObject body = createEventBody();
    body.remove("level");
    StringReader reader = new StringReader(body.toJSONString());
    JSONEvent event = resource.getRequestBody(reader);
    resource.validateEventProperties(event);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:13,代碼來源:EventResourceTest.java

示例7: Node

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Creates a new {@code Node} that corresponds to the given JSONObject.
 * 
 * @param node JSONObject describing the node.
 */
Node(JSONObject node) {
    this.properties = node;

    // Children
    Object childrenValue = node.get("children"); // NOI18N
    if (childrenValue != null) {
        initChildren();
        JSONArray childrenArray = (JSONArray)childrenValue;
        List<Node> newChildren = new ArrayList<Node>(childrenArray.size());
        for (Object child : childrenArray) {
            newChildren.add(new Node((JSONObject)child));
        }
        addChildren(newChildren);
    }

    Object shadowRootsValue = node.get("shadowRoots"); // NOI18N
    if (shadowRootsValue instanceof JSONArray) {
        JSONArray shadowRootArray = (JSONArray)shadowRootsValue;
        for (Object shadowRoot : shadowRootArray) {
            addShadowRoot(new Node((JSONObject)shadowRoot));
        }
    }

    // Attributes
    JSONArray array = (JSONArray)getProperties().get("attributes"); // NOI18N
    if (array != null) {
        for (int i=0; i<array.size()/2; i++) {
            String name = (String)array.get(2*i);
            String value = (String)array.get(2*i+1);
            setAttribute(name, value);
        }
    }

    // Content document
    JSONObject document = (JSONObject)getProperties().get("contentDocument"); // NOI18N
    if (document != null) {
        contentDocument = new Node(document);
        contentDocument.parent = this;
        // A node cannot have both children and content document.
        // FRAME doesn't support children at all and children
        // of IFRAME are interpreted when frames are not supported
        // only (i.e. when the content document is null)
        // => no need to ask for children of a node with a content
        // document. We can set children to empty collection immediately.
        initChildren();
    }

    // Cleanup
    node.remove("children"); // NOI18N
    node.remove("attributes"); // NOI18N
    node.remove("contentDocument"); // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:58,代碼來源:Node.java

示例8: getData

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
/**
 * Connects to the server and downloads information as specified in the GUI.
 * Will block until data is received but can be stopped by pressing the 
 * back (escape) button. Throws various Exceptions if errors occur such as not 
 * being able to connect to the server.
 * 
 * @return A Map containing all information specified by the professors.
 * @throws IOException
 *             If there is an error communicating with the server.
 * @throws UnknownHostException
 *             If the server cannot be found.
 * @throws ParseException
 *             If an error occurs in parsing data from the server.
 * @see java.util.Map
 */
public Map getData() throws IOException, UnknownHostException, ParseException {

	if (this.debugPrint)
		System.out.println("Connecting...");

	// Connect to server, set timeout
	Socket conn = new Socket(serverIP, portNumber);
	conn.setSoTimeout(timeout);

	// Create a thread to monitor the escape (back) button in case user
	// wants to exit
	Thread buttonChk = new Thread(new exitButtonChecker(this.debugPrint, conn));
	buttonChk.start();

	BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	PrintWriter writer = new PrintWriter(conn.getOutputStream(), true);

	if (this.debugPrint)
		System.out.println("Connected. Sending request.");

	// Create data to send to server
	JSONObject obj = new JSONObject();
	obj.put("Type", "REQ");
	obj.put("Team Number", new Integer(this.teamNumber));

	// Send data to server
	writer.println(obj.toJSONString());

	if (this.debugPrint)
		System.out.println("Request sent; waiting for response");

	// Wait for and read response from server
	String response = reader.readLine();

	// Process response from server
	JSONObject rJSONObject = (JSONObject) JSONValue.parse(response);

	if (!rJSONObject.containsKey("Type") || !rJSONObject.get("Type").equals("RESP")
			|| !rJSONObject.containsKey("Status")) {
		throw new IOException("Corrupted data received");
	} else if (rJSONObject.containsKey("Status") && !rJSONObject.get("Status").equals("OK")) {
		throw new IOException("Bad server status: " + rJSONObject.get("Status"));
	} else if (this.debugPrint) {
		System.out.println("Response received OK.");
	}

	// Remove type and status as they are not needed by the user
	rJSONObject.remove("Type");
	rJSONObject.remove("Status");

	// Clean up: close connection, terminate button watch thread, return
	// data to caller
	conn.close();

	buttonChk.interrupt();

	return rJSONObject;
}
 
開發者ID:alisharif2,項目名稱:dpm-project,代碼行數:75,代碼來源:WifiConnection.java

示例9: JSONObject

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * BoxとRelationのLink削除時に単一キーの同名Relationが存在すると409になること.
 */
@Test
@SuppressWarnings("unchecked")
public final void BoxとRelationのLink削除時に単一キーの同名Relationが存在すると409になること() {
    final String boxName = "relationLinkBox";
    final String relationName = "boxLinkRelation";
    try {
        // Boxの作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN, HttpStatus.SC_CREATED);

        // 上のBoxと結びつくRelation作成
        JSONObject body = new JSONObject();
        body.put("Name", relationName);
        body.put("_Box.Name", boxName);
        RelationUtils.create(CELL_NAME, TOKEN, body, HttpStatus.SC_CREATED);

        // 上のBoxと結びつかないRelation作成
        body.remove("_Box.Name");
        RelationUtils.create(CELL_NAME, TOKEN, body, HttpStatus.SC_CREATED);

        String relationKeyName = "_Box.Name='" + boxName + "',Name='" + relationName + "'";

        // BoxとRelationのLink削除(単一キーのRelationが存在するため削除できない(409))
        deleteBoxRelationLink(boxName, relationKeyName, HttpStatus.SC_CONFLICT);
        // RelationとBoxのLink削除(逆向きでも同様に409)
        deleteRelationBoxLink(relationKeyName, boxName, HttpStatus.SC_CONFLICT);

        // Relationの削除
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, null, HttpStatus.SC_NO_CONTENT);

        // BoxとRelationのLink削除(単一キーのRelationが存在しないので削除できる)
        deleteBoxRelationLink(boxName, relationKeyName, HttpStatus.SC_NO_CONTENT);

        // 結びつくRelationの削除
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, null, HttpStatus.SC_NO_CONTENT);

        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくRelationの削除
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, boxName, -1);
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, null, -1);

        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:50,代碼來源:BoxRelationLinkTest.java

示例10: tick

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Called every tick
 */
public void tick() {

    JSONObject json = new JSONObject();
    json.put("t", "tick");

    LogManager.LOGGER.info("Notified " + userManager.getOnlineUsers().size() + " users");

    ArrayList<OnlineUser> onlineUsers = new ArrayList<>(userManager.getOnlineUsers()); //Avoid ConcurrentModificationException
    for (OnlineUser user : onlineUsers) {

        if (user.getWebSocket().isOpen()) {

            if (user.isGuest()) {

                json.remove("c");
                user.getWebSocket().send(json.toJSONString());

            } else {
                try {
                    ControllableUnit unit = user.getUser().getControlledUnit();

                    //Send keyboard updated buffer
                    ArrayList<Integer> kbBuffer = unit.getKeyboardBuffer();
                    JSONArray keys = new JSONArray();
                    keys.addAll(kbBuffer);
                    json.put("keys", keys);

                    //Send console buffer
                    if (unit.getConsoleMessagesBuffer().size() > 0) {

                        JSONArray buff = new JSONArray();

                        for (char[] message : unit.getConsoleMessagesBuffer()) {
                            buff.add(new String(message));
                        }

                        json.put("c", buff);
                    } else {
                        json.remove("c");
                    }

                    json.put("cm", unit.getConsoleMode());


                    //Send tick message
                    user.getWebSocket().send(json.toJSONString());
                } catch (NullPointerException e) {
                    //User is online but not completely initialised
                }

            }


        }
    }

}
 
開發者ID:simon987,項目名稱:Much-Assembly-Required,代碼行數:61,代碼來源:SocketServer.java


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