diff --git a/JSONArray.java b/JSONArray.java index f338a2d..b2f505e 100644 --- a/JSONArray.java +++ b/JSONArray.java @@ -78,7 +78,7 @@ import java.util.Map; * * * @author JSON.org - * @version 2016-03-05 + * @version 2016-05-13 */ public class JSONArray implements Iterable { @@ -960,6 +960,25 @@ public class JSONArray implements Iterable { return this; } + /** + * Creates a JSONPointer using an intialization string and tries to + * match it to an item within this JSONArray. For example, given a + * JSONArray initialized with this document: + *
+     * [
+     *     {"b":"c"}
+     * ]
+     * 
+ * and this JSONPointer string: + *
+     * "/0/b"
+     * 
+ * Then this method will return the String "c" + * A JSONPointerException may be thrown from code called by this method. + * + * @param jsonPointer string that can be used to create a JSONPointer + * @return the item matched by the JSONPointer, otherwise null + */ public Object query(String jsonPointer) { return new JSONPointer(jsonPointer).queryFrom(this); } diff --git a/JSONObject.java b/JSONObject.java index f2f0f7d..4244220 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -93,7 +93,7 @@ import java.util.Set; * * * @author JSON.org - * @version 2016-05-01 + * @version 2016-05-13 */ public class JSONObject { /** @@ -1337,7 +1337,26 @@ public class JSONObject { } return this; } - + + /** + * Creates a JSONPointer using an intialization string and tries to + * match it to an item within this JSONObject. For example, given a + * JSONObject initialized with this document: + *
+     * {
+     *     "a":{"b":"c"}
+     * }
+     * 
+ * and this JSONPointer string: + *
+     * "/a/b"
+     * 
+ * Then this method will return the String "c". + * A JSONPointerException may be thrown from code called by this method. + * + * @param jsonPointer string that can be used to create a JSONPointer + * @return the item matched by the JSONPointer, otherwise null + */ public Object query(String jsonPointer) { return new JSONPointer(jsonPointer).queryFrom(this); } diff --git a/JSONPointer.java b/JSONPointer.java index 820a448..e27ad9e 100644 --- a/JSONPointer.java +++ b/JSONPointer.java @@ -35,7 +35,10 @@ SOFTWARE. /** * A JSON Pointer is a simple query language defined for JSON documents by - * RFC 6901. + * RFC 6901. + * + * @author JSON.org + * @version 2016-05-13 */ public class JSONPointer { diff --git a/JSONPointerException.java b/JSONPointerException.java index e3d20a9..0ce1aeb 100644 --- a/JSONPointerException.java +++ b/JSONPointerException.java @@ -27,6 +27,9 @@ SOFTWARE. /** * The JSONPointerException is thrown by {@link JSONPointer} if an error occurs * during evaluating a pointer. + * + * @author JSON.org + * @version 2016-05-13 */ public class JSONPointerException extends JSONException { private static final long serialVersionUID = 8872944667561856751L;