diff --git a/api/src/org/labkey/api/action/ApiXmlWriter.java b/api/src/org/labkey/api/action/ApiXmlWriter.java index 54609421ab9..f5056f17d35 100644 --- a/api/src/org/labkey/api/action/ApiXmlWriter.java +++ b/api/src/org/labkey/api/action/ApiXmlWriter.java @@ -99,10 +99,24 @@ else if (value instanceof JSONObject) { writeJsonObjInternal((JSONObject) value); } + // -------------------------------- + // DO NOT MERGE THIS FORWARD + else if (value instanceof org.json.JSONObject jo) + { + writeJsonObjInternal(jo); + } + //--------------------------------- else if (value instanceof JSONArray) { writeJsonArray((JSONArray) value); } + // -------------------------------- + // DO NOT MERGE THIS FORWARD + else if (value instanceof org.json.JSONArray ja) + { + writeJsonArray(ja); + } + //--------------------------------- else if (value instanceof Map) { writeJsonObjInternal(new JSONObject((Map) value)); @@ -150,6 +164,19 @@ private void writeJsonArray(JSONArray jsonArray) throws XMLStreamException, IOEx } } + // -------------------------------- + // DO NOT MERGE THIS FORWARD + private void writeJsonArray(org.json.JSONArray jsonArray) throws XMLStreamException, IOException + { + verifyOpen(); + for (int i = 0; i < jsonArray.length(); i++) + { + _xmlWriter.writeStartElement(ARRAY_ELEMENT_NAME); + writeObject(jsonArray.get(i)); + _xmlWriter.writeEndElement(); + } + } + // -------------------------------- @Override public void close() throws IOException @@ -180,6 +207,19 @@ protected void writeJsonObjInternal(JSONObject obj) throws IOException, XMLStrea } } + // -------------------------------- + // DO NOT MERGE THIS FORWARD + protected void writeJsonObjInternal(org.json.JSONObject json) throws IOException, XMLStreamException + { + verifyOpen(); + for (String key : json.keySet()) + { + _xmlWriter.writeStartElement(escapeElementName(key)); + writeObject(json.get(key)); + _xmlWriter.writeEndElement(); + } + } + // -------------------------------- @Override public void startResponse()