Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/utilcode/src/main/java/com/blankj/utilcode/util/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ private JsonUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}


/**
* Checks if a given input is a JSONObject.
*
* @param input Anything.
* @return true if it is a JSONObject.
*/
public static <T> boolean isJSONObject(final T input) {
return input instanceof JSONObject;
}

/**
* Checks if a given input is a JSONArray
*
* @param input Anything.
* @return true if it is a JSONArray.
*/
public static <T> boolean isJSONArray(final T input) {
return input instanceof JSONArray;
}

public static boolean getBoolean(final JSONObject jsonObject,
final String key) {
return getBoolean(jsonObject, key, false);
Expand Down