added JSONObject#query() and JSONPointer#query() methods · svanteschubert/JSON-java@45bd72c · GitHub
Skip to content

Commit 45bd72c

Browse files
committed
added JSONObject#query() and JSONPointer#query() methods
1 parent 792c6f6 commit 45bd72c

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

JSONArray.java

Lines changed: 9 additions & 1 deletion

JSONObject.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ of this software and associated documentation files (the "Software"), to deal
3232
import java.lang.reflect.Modifier;
3333
import java.math.BigDecimal;
3434
import java.math.BigInteger;
35-
import java.util.*;
35+
import java.util.Collection;
36+
import java.util.Enumeration;
37+
import java.util.HashMap;
38+
import java.util.Iterator;
39+
import java.util.Locale;
40+
import java.util.Map;
3641
import java.util.Map.Entry;
42+
import java.util.ResourceBundle;
43+
import java.util.Set;
3744

3845
/**
3946
* A JSONObject is an unordered collection of name/value pairs. Its external
@@ -1330,6 +1337,10 @@ public JSONObject putOpt(String key, Object value) throws JSONException {
13301337
}
13311338
return this;
13321339
}
1340+
1341+
public Object query(String jsonPointer) {
1342+
return new JSONPointer(jsonPointer).queryFrom(this);
1343+
}
13331344

13341345
/**
13351346
* Produce a string in double quotes with backslash sequences in all the

JSONPointer.java

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)