Java Code Examples for org.json.JSONObject#equals()
The following examples show how to use
org.json.JSONObject#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginManager.java From plugin-installation-manager-tool with MIT License | 6 votes |
/** * Gets the JSONArray containing plugin a * * @param plugin to get depedencies for * @param ucJson update center json from which to parse dependencies * @return JSONArray containing plugin dependencies */ public JSONArray getPluginDependencyJsonArray(Plugin plugin, JSONObject ucJson) { JSONObject plugins = ucJson.getJSONObject("plugins"); if (!plugins.has(plugin.getName())) { return null; } JSONObject pluginInfo = (JSONObject) plugins.get(plugin.getName()); if (ucJson.equals(pluginInfoJson)) { //plugin-versions.json has a slightly different structure than other update center json if (pluginInfo.has(plugin.getVersion().toString())) { JSONObject specificVersionInfo = pluginInfo.getJSONObject(plugin.getVersion().toString()); plugin.setJenkinsVersion(specificVersionInfo.getString("requiredCore")); return (JSONArray) specificVersionInfo.get("dependencies"); } } else { plugin.setJenkinsVersion(pluginInfo.getString("requiredCore")); //plugin version is latest or experimental String version = pluginInfo.getString("version"); plugin.setVersion(new VersionNumber(version)); return (JSONArray) pluginInfo.get("dependencies"); } return null; }
Example 2
Source File: NetworkManager.java From ultimate-cordova-webview-app with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { LOG.d(LOG_TAG, e.getLocalizedMessage()); } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 3
Source File: NetworkManager.java From ultimate-cordova-webview-app with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { LOG.d(LOG_TAG, e.getLocalizedMessage()); } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 4
Source File: NetworkManager.java From showCaseCordova with Apache License 2.0 | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 5
Source File: NetworkManager.java From reader with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 6
Source File: NetworkManager.java From reader with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 7
Source File: NetworkManager.java From reader with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 8
Source File: NetworkManager.java From reader with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 9
Source File: NetworkManager.java From jpHolo with MIT License | 6 votes |
/** * Updates the JavaScript side whenever the connection changes * * @param info the current active network info * @return */ private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info JSONObject thisInfo = this.getConnectionInfo(info); if(!thisInfo.equals(lastInfo)) { String connectionType = ""; try { connectionType = thisInfo.get("type").toString(); } catch (JSONException e) { } sendUpdate(connectionType); lastInfo = thisInfo; } }
Example 10
Source File: Utility.java From kognitivo with Apache License 2.0 | 5 votes |
public static boolean hasSameId(JSONObject a, JSONObject b) { if (a == null || b == null || !a.has("id") || !b.has("id")) { return false; } if (a.equals(b)) { return true; } String idA = a.optString("id"); String idB = b.optString("id"); if (idA == null || idB == null) { return false; } return idA.equals(idB); }
Example 11
Source File: JsonSerializable.java From rheem with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public T deserialize(JSONObject json, Class<? extends T> cls) { if (json == null || json.equals(JSONObject.NULL)) return null; try { final Method fromJsonMethod = cls.getMethod("fromJson", JSONObject.class); return (T) fromJsonMethod.invoke(null, json); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new RheemException(String.format("Could not execute %s.fromJson(...).", cls.getCanonicalName()), e); } }
Example 12
Source File: CreateMicrostory.java From EventCoreference with Apache License 2.0 | 5 votes |
public static ArrayList<JSONObject> getEventsThroughFrameNetBridging(ArrayList<JSONObject> events, JSONObject event, FrameNetReader frameNetReader) throws JSONException { ArrayList<JSONObject> fnRelatedEvents = new ArrayList<JSONObject>(); JSONArray superFrames = (JSONArray) event.get("fnsuperframes"); if (superFrames!=null) { for (int j = 0; j < superFrames.length(); j++) { String frame = (String) superFrames.get(j); for (int i = 0; i < events.size(); i++) { JSONObject oEvent = events.get(i); if (!oEvent.equals(event)) { JSONArray oSuperFrames = (JSONArray) oEvent.get("fnsuperframes"); for (int k = 0; k < oSuperFrames.length(); k++) { String oFrame = (String) oSuperFrames.get(k); if (frame.equals(oFrame)) { if (!fnRelatedEvents.contains(oEvent)) { fnRelatedEvents.add(oEvent); } break; } } } } } } return fnRelatedEvents; }
Example 13
Source File: CreateMicrostory.java From EventCoreference with Apache License 2.0 | 5 votes |
public static ArrayList<JSONObject> getEventsThroughEsoBridging(ArrayList<JSONObject> events, JSONObject event, FrameNetReader frameNetReader) throws JSONException { ArrayList<JSONObject> esoRelatedEvents = new ArrayList<JSONObject>(); JSONArray superFrames = (JSONArray) event.get("esosuperclasses"); if (superFrames!=null) { for (int j = 0; j < superFrames.length(); j++) { String frame = (String) superFrames.get(j); for (int i = 0; i < events.size(); i++) { JSONObject oEvent = events.get(i); if (!oEvent.equals(event)) { JSONArray oSuperFrames = (JSONArray) oEvent.get("esosuperclasses"); for (int k = 0; k < oSuperFrames.length(); k++) { String oFrame = (String) oSuperFrames.get(k); if (frame.equals(oFrame)) { if (!esoRelatedEvents.contains(oEvent)) { esoRelatedEvents.add(oEvent); } break; } } } } } } return esoRelatedEvents; }
Example 14
Source File: Capability7Tests.java From FROST-Server with GNU Lesser General Public License v3.0 | 4 votes |
private static boolean jsonEquals(JSONObject obj1, JSONObject obj2) { if (obj1 == null) { return obj2 == null; } if (obj1.equals(obj2)) { return true; } if (obj1.getClass() != obj2.getClass()) { return false; } if (obj1.length() != obj2.length()) { return false; } Iterator iterator = obj1.keys(); while (iterator.hasNext()) { String key = iterator.next().toString(); if (!obj2.has(key)) { return false; } try { Object val1 = obj1.get(key); if (val1 instanceof JSONObject) { if (!jsonEquals((JSONObject) val1, (JSONObject) obj2.getJSONObject(key))) { return false; } } else if (val1 instanceof JSONArray) { JSONArray arr1 = (JSONArray) val1; JSONArray arr2 = obj2.getJSONArray(key); if (!jsonEquals(arr1, arr2)) { return false; } } // check here for properties ending on 'time" else if (key.toLowerCase().endsWith("time")) { if (!checkTimeEquals(val1.toString(), obj2.get(key).toString())) { return false; } } else if (!val1.equals(obj2.get(key))) { return false; } } catch (JSONException ex) { return false; } } return true; }
Example 15
Source File: JsonSerializables.java From rheem with Apache License 2.0 | 2 votes |
/** * Deserialize a {@link JSONObject} with a {@link JsonSerializer}. * * @param jsonObject the {@link JSONObject} * @param serializer the {@link JsonSerializer} * @param cls the {@link Class} of the deserialization product * @return the deserialization product */ public static <T> T deserialize(JSONObject jsonObject, JsonSerializer<T> serializer, Class<? extends T> cls) { if (jsonObject == null || jsonObject.equals(JSONObject.NULL)) return null; return serializer.deserialize(jsonObject, cls); }