From 7a8da886e7cc816ddd50f01ca3ae76673d07a671 Mon Sep 17 00:00:00 2001 From: Pratik Tiwari Date: Fri, 30 Jan 2026 19:29:46 +0530 Subject: [PATCH] Remove unnecessary conditions --- src/main/java/org/json/XML.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/json/XML.java b/src/main/java/org/json/XML.java index d0216f5..539285d 100644 --- a/src/main/java/org/json/XML.java +++ b/src/main/java/org/json/XML.java @@ -391,7 +391,7 @@ public class XML { context.append(tagName, JSONObject.NULL); } else if (jsonObject.length() > 0) { context.append(tagName, jsonObject); - } else if(context.isEmpty() && (context.opt(tagName) == null || !(context.get(tagName) instanceof JSONArray))) { //avoids resetting the array in case of an empty tag in the middle or end + } else if(context.isEmpty()) { //avoids resetting the array in case of an empty tag in the middle or end context.put(tagName, new JSONArray()); } } else { @@ -452,7 +452,7 @@ public class XML { // Force the value to be an array if (jsonObject.length() == 0) { //avoids resetting the array in case of an empty element in the middle or end - if(context.length()==0 && context.opt(tagName) == null || !(context.get(tagName) instanceof JSONArray)) { + if(context.isEmpty()) { context.put(tagName, new JSONArray()); } } else if (jsonObject.length() == 1