@Deprecated public static boolean hasComplexKey(Object object, String key) throws JSONException { final Object json = tryParseJson(object, true); if (!isComplexKey(key) || !isJson(json)) return false; return (processComplexKey(json, KEY_PATTERN.split(key)).size() > 0); }
/** If "ref" is not a String, the default value is returned regardless. */ @Override public Object opt(Object ref, Object defaultValue) { if (ref instanceof String) { // Try it the way the parent would do it first final Object object = super.opt((String) ref); // If that fails, try parsing ref as an array key if (object == null) try { if (EwJson.isComplexKey(ref)) return EwJson.derefComplexKey(this, (String) ref); } catch (JSONException e) { } return object; } return defaultValue; }
@Override public Object opt(Object ref, Object defaultValue) { // Try it the way the parent would do it first final Object object = super.opt(EwJson.keyToIndex(ref)); // If that fails, try parsing ref as a composite key if (object == null && ref instanceof String) try { if (EwJson.isComplexKey(ref)) return EwJson.derefComplexKey(this, (String) ref); } catch (JSONException e) { } return (object == null) ? defaultValue : object; }
@Deprecated public static Object derefComplexKey(Object object, String key) throws JSONException { if (isNull(object)) return null; if (!isComplexKey(key)) return getElement(object, key); final EwList<Object> results = processComplexKey(object, KEY_PATTERN.split(key)); switch (results.size()) { case 0: return null; case 1: return results.get(0); default: return results; } }