@Override public void pathEnd(String path) { destTree.merge(destBranch); }
public void merge(Object o2) { merge(this, o2); }
@Override public void pathEnd(String path) { destTree.merge(destBranch); }
public void merge(Object o2) { merge(this, o2); }
public void merge(Object o2) { JSONObject.merge(this, o2); }
public void merge(Object o2) { JSONObject.merge(this, o2); }
protected static JSONObject merge(JSONObject o1, Object o2) { if (o2 == null) return o1; if (o2 instanceof JSONObject) return merge(o1, (JSONObject) o2); throw new RuntimeException("JSON megre can not merge JSONObject with " + o2.getClass()); }
protected static JSONObject merge(JSONObject o1, Object o2) { if (o2 == null) return o1; if (o2 instanceof JSONObject) return merge(o1, (JSONObject) o2); throw new RuntimeException("JSON megre can not merge JSONObject with " + o2.getClass()); }
protected static JSONArray merge(JSONArray o1, Object o2) { if (o2 == null) return o1; if (o1 instanceof JSONArray) return merge(o1, (JSONArray) o2); o1.add(o2); return o1; }
protected static JSONArray merge(JSONArray o1, Object o2) { if (o2 == null) return o1; if (o1 instanceof JSONArray) return merge(o1, (JSONArray) o2); o1.add(o2); return o1; }
private static JSONObject merge(JSONObject o1, JSONObject o2) { if (o2 == null) return o1; for (String key : o1.keySet()) { Object value1 = o1.get(key); Object value2 = o2.get(key); if (value2 == null) continue; if (value1 instanceof JSONArray) { o1.put(key, merge((JSONArray) value1, value2)); continue; } if (value1 instanceof JSONObject) { o1.put(key, merge((JSONObject) value1, value2)); continue; } if (value1.equals(value2)) continue; if (value1.getClass() .equals(value2.getClass())) throw new RuntimeException("JSON merge can not merge two " + value1.getClass().getName() + " Object together"); throw new RuntimeException("JSON merge can not merge " + value1.getClass().getName() + " with " + value2.getClass().getName()); } for (String key : o2.keySet()) { if (o1.containsKey(key)) continue; o1.put(key, o2.get(key)); } return o1; }
private static JSONObject merge(JSONObject o1, JSONObject o2) { if (o2 == null) return o1; for (String key : o1.keySet()) { Object value1 = o1.get(key); Object value2 = o2.get(key); if (value2 == null) continue; if (value1 instanceof JSONArray) { o1.put(key, merge((JSONArray) value1, value2)); continue; } if (value1 instanceof JSONObject) { o1.put(key, merge((JSONObject) value1, value2)); continue; } if (value1.equals(value2)) continue; if (value1.getClass() .equals(value2.getClass())) throw new RuntimeException("JSON merge can not merge two " + value1.getClass().getName() + " Object together"); throw new RuntimeException("JSON merge can not merge " + value1.getClass().getName() + " with " + value2.getClass().getName()); } for (String key : o2.keySet()) { if (o1.containsKey(key)) continue; o1.put(key, o2.get(key)); } return o1; }