From a490ebdb7852768364a9e577f89c3871c4d3392c Mon Sep 17 00:00:00 2001 From: Andrei Paikin Date: Sat, 19 May 2018 09:42:21 +0300 Subject: [PATCH] add isEmpty and isNotEmpty methods --- JSONObject.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/JSONObject.java b/JSONObject.java index d18a556..a6ece64 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -963,6 +963,24 @@ public class JSONObject { return this.map.size(); } + /** + * Check if JSONObject is empty. + * + * @return true if JSONObject is empty, otherwise false. + */ + public boolean isEmpty() { + return map.isEmpty(); + } + + /** + * Check if JSONObject is not empty. + * + * @return true if JSONObject is not empty, otherwise false. + */ + public boolean isNotEmpty() { + return !map.isEmpty(); + } + /** * Produce a JSONArray containing the names of the elements of this * JSONObject.