From 8da7c0cd80891cf414e1ea919b288f43ee109f71 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Fri, 9 Oct 2015 14:47:46 +0200 Subject: [PATCH] Added path resolution extension to JSONObject.has(String) --- JSONObject.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/JSONObject.java b/JSONObject.java index 4159c0fed..92d4c20bc 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -748,7 +748,16 @@ public String getString(String key) throws JSONException { * @return true if the key exists in the JSONObject. */ public boolean has(String key) { - return this.map.containsKey(key); + if (key.indexOf(delimiter) != -1 || key.indexOf(leftBracket) != -1) { + try { + get(key); + return true; + } catch (JSONException e) { + return false; + } + } else { + return this.map.containsKey(key); + } } /**