From 6b8035500788e0524f2917776aacab131adb3bd9 Mon Sep 17 00:00:00 2001 From: Thomas Bucher Date: Tue, 24 Jul 2018 11:18:17 +0200 Subject: [PATCH] Added Prefix for create a JsonArray To Force a JsonArray int to Output from XML even if there is only one entry, i added __jsonarray__ as a quick and dirty prefix to force creation of an JsonArray instead of a JsonObject --- JSONObject.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/JSONObject.java b/JSONObject.java index 8deb6bae5..dbcda1bb4 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -476,6 +476,10 @@ protected JSONObject(int initialCapacity){ */ public JSONObject accumulate(String key, Object value) throws JSONException { testValidity(value); + if (key.toLowerCase().startsWith("__jsonarray__")) { + key = key.substring(13); + this.put(key,new JSONArray()); + } Object object = this.opt(key); if (object == null) { this.put(key,