@Deprecated public static Object wrap(Object object) { return wrap(object, false); }
/** Overridden to first wrap the value for consistency. */ @Override public EwJsonArray put(Object value) { super.put(EwJson.wrap(value)); return this; }
public EwJsonArray(Collection collection) { this(); if (collection != null) { final Iterator iter = collection.iterator(); while (iter.hasNext()) this.put(EwJson.wrap(iter.next())); } }
@SuppressWarnings("unchecked") @Deprecated public static JSONObject merge(JSONObject into, JSONObject from) { if (into == null) return null; if (from == null) return into; try { Iterator<String> keys = from.keys(); while (keys.hasNext()) { String s = keys.next(); into.put(s, wrap(from.get(s))); } } catch (JSONException ex) { } return into; }
/** * Overridden to first try parsing value as an EwJsonCollection. All puts * executed in the parent call this method. Null values result in the * removal of any existing value at key. */ @Override public synchronized EwJsonObject put(String key, Object value) throws JSONException { Object wrapped = EwJson.wrap(value); orderedKeys.add(key); if (EwJson.isNull(wrapped)) super.put(key, (Object) null); else super.put(key, wrapped); return this; }
/** * Overridden to first try wrapping as a valid JSON value. All index-based * puts in parent call this method. All index-based puts also pad the * underlying {@link ArrayList} with null values when index is beyond the * current range of the array. */ @Override public EwJsonArray put(int index, Object value) throws JSONException { Object wrapped = EwJson.wrap(value); if (EwJson.isNull(wrapped)) super.put(index, (Object) null); else super.put(index, wrapped); return this; }
public EwJsonObject(Map map) { this(); if (map == null) return; try { final Iterator keys = map.entrySet().iterator(); while (keys.hasNext()) { final Map.Entry entry = (Map.Entry) keys.next(); final Object value = entry.getValue(); if (value != null) this.put(entry.getKey(), EwJson.wrap(value)); } } catch (JSONException je) { } }
@Deprecated public static JSONArray merge(JSONArray into, JSONArray from, int startCopy, int startPut, int length) { if (into == null) return null; if (from == null) return into; if (!isValidIndex(from, startCopy)) return into; try { // Loop may break before limit final int limit = (startCopy + length); final int to = (startPut < 0) ? into.length() // Start after last // element : startPut; // Start at specified element for (int here = to, there = startCopy; there < limit; here++, there++) { if (there < from.length()) into.put(here, wrap(from.get(there))); else break; // Nothing more to copy } } catch (JSONException ex) { } return into; }
result.put(key, ((Boolean) value).booleanValue()); else result.put(key, EwJson.wrap(value, true));
/** * Compares this with object, after it has been wrapped by * {@link EwJson#wrap(Object)}. */ @Override public boolean equals(Object object) { if (super.equals(object)) return true; final Object wrapped = EwJson.wrap(object); if (this == wrapped) return true; if (EwJson.isNull(wrapped)) return false; if (wrapped instanceof EwJsonCollection) return EwJson.equals(this, (EwJsonCollection) wrapped); return false; }
/** * Compares this with object, after it has been wrapped by * {@link EwJson#wrap(Object)}. */ @Override public boolean equals(Object object) { if (super.equals(object)) return true; final Object wrapped = EwJson.wrap(object); if (this == wrapped) return true; if (EwJson.isNull(wrapped)) return false; if (wrapped instanceof EwJsonCollection) return EwJson.equals(this, (EwJsonCollection) wrapped); return false; }
ewObject.put(key, wrap(result));
this.put(EwJson.wrap(Array.get(source, i)));
result.put(key, ((Boolean) value).booleanValue()); else result.put(key, EwJson.wrap(value, true));
into.put(new Integer(i).toString(), EwJson.wrap(from.get(i)));
final Object wrapped = EwJson.wrap(from, true);
final Object wrapped = EwJson.wrap(from, true);