@Override public void removeProperty(Object obj, Object key) { try { if( obj instanceof org.codehaus.jettison.json.JSONArray ) { int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString()); if( index<length(obj) ) { Object temp = new Object(); // Need FIX: JSONArray.remove(int) ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp); ((org.codehaus.jettison.json.JSONArray)obj).remove(temp); } } if( obj instanceof org.codehaus.jettison.json.JSONObject ) { ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key)); } } catch( org.codehaus.jettison.json.JSONException jsonException ) { throw new IllegalStateException(jsonException); } }
@Override public void removeProperty(Object obj, Object key) { try { if( obj instanceof org.codehaus.jettison.json.JSONArray ) { int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString()); if( index<length(obj) ) { Object temp = new Object(); // Need FIX: JSONArray.remove(int) ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp); ((org.codehaus.jettison.json.JSONArray)obj).remove(temp); } } if( obj instanceof org.codehaus.jettison.json.JSONObject ) { ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key)); } } catch( org.codehaus.jettison.json.JSONException jsonException ) { throw new IllegalStateException(jsonException); } }
this.myHashMap.put(key, null); } else { remove(key);
private void clearArrayItems() { object.remove("items"); this.arrayItems = null; } }
private void clearProperties() { object.remove("properties"); this.properties=null; }
@Override public void removeProperty(Object obj, Object key) { try { if( obj instanceof org.codehaus.jettison.json.JSONArray ) { int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString()); if( index<length(obj) ) { Object temp = new Object(); // Need FIX: JSONArray.remove(int) ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp); ((org.codehaus.jettison.json.JSONArray)obj).remove(temp); } } if( obj instanceof org.codehaus.jettison.json.JSONObject ) { ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key)); } } catch( org.codehaus.jettison.json.JSONException jsonException ) { throw new IllegalStateException(jsonException); } }
/** * Put a key/value pair in the JSONObject. If the value is null, * then the key will be removed from the JSONObject if it is present. * @param key A key string. * @param value An object which is the value. It should be of one of these * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, * or the JSONObject.NULL object. * @return this. * @throws JSONException If the value is non-finite number * or if the key is null. */ public JSONObject put(String key, Object value) throws JSONException { if (key == null) { throw new JSONException("Null key."); } if (value != null) { testValidity(value); this.myHashMap.put(key, value); } else { remove(key); } return this; }
@Override public String getSchemaJSON() { if (!changed && schemaJSON != null) { return schemaJSON; } if (schemaKeys == null) { schema.remove(Schema.FIELD_SCHEMA_KEYS); } else { try { schema.put(Schema.FIELD_SCHEMA_KEYS, SchemaUtils.createJSONObject(schemaKeys)); } catch (JSONException ex) { throw new RuntimeException(ex); } } schemaJSON = schema.toString(); return schemaJSON; }
public static FaunusVertex fromJSON(String line) throws IOException { try { final JSONObject json = new JSONObject(new JSONTokener(line)); line = EMPTY_STRING; // clear up some memory final FaunusVertex vertex = (FaunusVertex) graphson.vertexFromJson(json); fromJSONEdges(vertex, json.optJSONArray(_OUT_E), OUT); json.remove(_OUT_E); // clear up some memory fromJSONEdges(vertex, json.optJSONArray(_IN_E), IN); json.remove(_IN_E); // clear up some memory return vertex; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private void readConfigEntries(JSONObject inpConfig, File clientInstallPath, JSONObject globalConfig, String name, String user) throws JSONException { JSONObject globalSection = inpConfig.getJSONObject("global"); Iterator it = globalSection.keys(); while (it.hasNext()) { String key = (String) it.next(); String value = globalSection.getString(key); if (SliderUtils.isSet(value)) { value = value.replace("{app_install_dir}", clientInstallPath.getAbsolutePath()); value = value.replace("{app_user}", user); if (name != null) { value = value.replace("{app_name}", name); } } if (globalConfig.has(key)) { // last one wins globalConfig.remove(key); } globalConfig.put(key, value); } }
private void readConfigEntries(JSONObject inpConfig, File clientInstallPath, JSONObject globalConfig, String name, String user) throws JSONException { JSONObject globalSection = inpConfig.getJSONObject("global"); Iterator it = globalSection.keys(); while (it.hasNext()) { String key = (String) it.next(); String value = globalSection.getString(key); if (SliderUtils.isSet(value)) { value = value.replace("{app_install_dir}", clientInstallPath.getAbsolutePath()); value = value.replace("{app_user}", user); if (name != null) { value = value.replace("{app_name}", name); } } if (globalConfig.has(key)) { // last one wins globalConfig.remove(key); } globalConfig.put(key, value); } }
/** * <p>removeProperty.</p> * * @param property a {@link JsonSchemaNode} object. */ public void removeProperty(JsonSchemaNode property){ JSONObject propertiesObject = null; try { propertiesObject = object.getJSONObject("properties"); } catch (JSONException e) { } if(propertiesObject==null) return; propertiesObject.remove(property.getName()); if(properties!=null) properties.remove(property.getName()); fireChanges(); }
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { String[] tmpArgs = new String[args.length - 2]; System.arraycopy(args, 2, tmpArgs, 0, args.length - 2); GetAppPackageInfoCommandLineInfo commandLineInfo = getGetAppPackageInfoCommandLineInfo(tmpArgs); try (AppPackage ap = newAppPackageInstance(new URI(args[1]), true)) { JSONSerializationProvider jomp = new JSONSerializationProvider(); jomp.addSerializer(PropertyInfo.class, new AppPackage.PropertyInfoSerializer(commandLineInfo.provideDescription)); JSONObject apInfo = new JSONObject(jomp.getContext(null).writeValueAsString(ap)); apInfo.remove("name"); printJson(apInfo); } } }
private void updateOpportunityInSalesForce(String accessToken, Opportunity opportunity) { LOGGER.info("About to flag opportunity as closed in SalesForce"); WebResource resource = createObjectsResource("/Opportunity/", opportunity.getId()).queryParam("_HttpMethod", "PATCH"); JSONObject memberJson = salesForceAdapter.createSaleForceRecordFromOpportunity(opportunity); // SalesForce doesn't allow the Id in the body memberJson.remove("Id"); ClientResponse response = doPostRequest(resource, memberJson, accessToken); checkAuthorization(response); checkResponse(response, 204, "Error updating opportunity in SalesForce"); }
private void updateContactInSalesForce(String accessToken, Contact contact) { LOGGER.info("About update contact in SalesForce"); String contactId = contact.getId(); validateSalesForceId(contactId); WebResource resource = createObjectsResource("/Contact/", contactId).queryParam("_HttpMethod", "PATCH"); JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromContact(contact); // SalesForce doesn't allow the Id in the body contactJson.remove("Id"); ClientResponse response = doPostRequest(resource, contactJson, accessToken); checkAuthorization(response); checkResponse(response, 204, "Error updating contact in SalesForce"); return; }
private void updateContactRoleInSalesForce(String accessToken, ContactRole contactRole) { LOGGER.info("About update contact role in SalesForce"); String contactRoleId = contactRole.getId(); validateSalesForceId(contactRoleId); WebResource resource = createObjectsResource("/Membership_Contact_Role__C/", contactRoleId).queryParam("_HttpMethod", "PATCH"); JSONObject contactRoleJson = salesForceAdapter.createSaleForceRecordFromContactRole(contactRole); // SalesForce doesn't allow the Id in the body contactRoleJson.remove("Id"); ClientResponse response = doPostRequest(resource, contactRoleJson, accessToken); checkAuthorization(response); checkResponse(response, 204, "Error updating contact role in SalesForce"); return; }
private void updateMemberInSalesForce(String accessToken, Member member) { LOGGER.info("About update member in SalesForce"); String accountId = member.getId(); validateSalesForceId(accountId); WebResource resource = createObjectsResource("/Account/", accountId).queryParam("_HttpMethod", "PATCH"); JSONObject memberJson = salesForceAdapter.createSaleForceRecordFromMember(member); // SalesForce doesn't allow the Id in the body memberJson.remove("Id"); ClientResponse response = doPostRequest(resource, memberJson, accessToken); checkAuthorization(response); checkResponse(response, 204, "Error updating member in SalesForce"); return; }
public static JSONObject toJSON(final Vertex vertex) throws IOException { try { final JSONObject object = GraphSONUtility.jsonFromElement(vertex, getElementPropertyKeys(vertex, false), GraphSONMode.COMPACT); // force the ID to long. with blueprints, most implementations will send back a long, but // some like TinkerGraph will return a string. the same is done for edges below object.put(GraphSONTokens._ID, Long.valueOf(object.remove(GraphSONTokens._ID).toString())); List<Edge> edges = (List<Edge>) vertex.getEdges(OUT); if (!edges.isEmpty()) { final JSONArray outEdgesArray = new JSONArray(); for (final Edge outEdge : edges) { final JSONObject edgeObject = GraphSONUtility.jsonFromElement(outEdge, getElementPropertyKeys(outEdge, true), GraphSONMode.COMPACT); outEdgesArray.put(edgeObject); } object.put(_OUT_E, outEdgesArray); } edges = (List<Edge>) vertex.getEdges(IN); if (!edges.isEmpty()) { final JSONArray inEdgesArray = new JSONArray(); for (final Edge inEdge : edges) { final JSONObject edgeObject = GraphSONUtility.jsonFromElement(inEdge, getElementPropertyKeys(inEdge, false), GraphSONMode.COMPACT); inEdgesArray.put(edgeObject); } object.put(_IN_E, inEdgesArray); } return object; } catch (JSONException e) { throw new IOException(e); } }
if (jsonObj.has(RegisterResponseParam.CLIENT_ID.toString())) { setClientId(jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString())); jsonObj.remove(RegisterResponseParam.CLIENT_ID.toString()); jsonObj.remove(CLIENT_SECRET.toString()); jsonObj.remove(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()); jsonObj.remove(REGISTRATION_CLIENT_URI.toString()); setClientIdIssuedAt(new Date(clientIdIssuedAt * 1000L)); jsonObj.remove(CLIENT_ID_ISSUED_AT.toString()); setClientSecretExpiresAt(new Date(clientSecretExpiresAt * 1000L)); jsonObj.remove(CLIENT_SECRET_EXPIRES_AT.toString());