public MappedXMLStreamReader(JSONObject obj, MappedNamespaceConvention con) throws JSONException, XMLStreamException { String rootName = (String) obj.keys().next(); this.convention = con; this.nodes = new FastStack(); this.ctx = con; Object top = obj.get(rootName); if (top instanceof JSONObject) { this.node = new Node(null, rootName, (JSONObject)top, convention); } else if (top instanceof JSONArray && !(((JSONArray)top).length() == 1 && ((JSONArray)top).get(0).equals(""))) { this.node = new Node(null, rootName, obj, convention); } else { node = new Node(rootName, convention); convention.processAttributesAndNamespaces(node, obj); currentValue = JSONObject.NULL.equals(top) ? null : top.toString(); } nodes.push(node); event = START_DOCUMENT; }