public static XdmNode convert(Processor processor, JSONTokener jt, String flavor) { TreeWriter tree = new TreeWriter(processor); tree.startDocument(null); if (JSONX.equals(flavor)) { buildJsonX(tree, jt); } else if (MARKLOGIC.equals(flavor)) { buildMarkLogic(tree, jt); } else if (JXML.equals(flavor)) { buildJxml(tree, jt); } else if (CALABASH.equals(flavor)) { buildMine(tree, jt, true); } else { buildMine(tree, jt, false); } tree.endDocument(); return tree.getResult(); }
private static void buildJsonX(TreeWriter tree, JSONTokener jt) { try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addStartElement(j_object); tree.startContent(); buildJsonXPairs(tree, new JSONObject(jt)); } else { tree.addStartElement(j_array); buildJsonXArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
private static void buildJxml(TreeWriter tree, JSONTokener jt) { try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addStartElement(jx_object); tree.startContent(); buildJxmlPairs(tree, new JSONObject(jt)); } else { tree.addStartElement(jx_array); buildJxmlArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
private static void buildMarkLogic(TreeWriter tree, JSONTokener jt) { tree.addStartElement(mj_json); try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addAttribute(_type, "object"); tree.startContent(); buildMarkLogicPairs(tree, new JSONObject(jt)); } else { tree.addAttribute(_type, "object"); buildMarkLogicArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
private static void buildMarkLogic(TreeWriter tree, JSONTokener jt) { tree.addStartElement(mj_json); try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addAttribute(_type, "object"); tree.startContent(); buildMarkLogicPairs(tree, new JSONObject(jt)); } else { tree.addAttribute(_type, "object"); buildMarkLogicArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
public static XdmNode convert(Processor processor, JSONTokener jt, String flavor) { TreeWriter tree = new TreeWriter(processor); tree.startDocument(null); if (JSONX.equals(flavor)) { buildJsonX(tree, jt); } else if (MARKLOGIC.equals(flavor)) { buildMarkLogic(tree, jt); } else if (JXML.equals(flavor)) { buildJxml(tree, jt); } else if (CALABASH.equals(flavor)) { buildMine(tree, jt, true); } else { buildMine(tree, jt, false); } tree.endDocument(); return tree.getResult(); }
private static void buildJsonX(TreeWriter tree, JSONTokener jt) { try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addStartElement(j_object); tree.startContent(); buildJsonXPairs(tree, new JSONObject(jt)); } else { tree.addStartElement(j_array); buildJsonXArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
private static void buildJxml(TreeWriter tree, JSONTokener jt) { try { char ch = jt.next(); jt.back(); if (ch == '{') { tree.addStartElement(jx_object); tree.startContent(); buildJxmlPairs(tree, new JSONObject(jt)); } else { tree.addStartElement(jx_array); buildJxmlArray(tree, new JSONArray(jt)); } } catch (JSONException je) { throw new XProcException(je); } tree.addEndElement(); }
tree.addAttribute(_type, "object"); tree.startContent(); buildMarkLogicPairs(tree, (JSONObject) json); } else if (json instanceof JSONArray) { tree.addAttribute(_type, "array"); tree.startContent(); buildMarkLogicArray(tree, (JSONArray) json); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) { tree.addAttribute(_type, "number");
if (name != null) { tree.addAttribute(_name, name); } tree.startContent(); buildJsonXPairs(tree, (JSONObject) json); tree.addEndElement(); } else if (json instanceof JSONArray) { if (name != null) { tree.addAttribute(_name, name); } tree.startContent(); buildJsonXArray(tree, (JSONArray) json); tree.addEndElement(); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) {
tree.addStartElement(jx_object); tree.startContent(); buildJxmlPairs(tree, (JSONObject) json); tree.addEndElement(); } else if (json instanceof JSONArray) { tree.addStartElement(jx_array); tree.startContent(); buildJxmlArray(tree, (JSONArray) json); tree.addEndElement(); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) {
tree.addAttribute(_type, "object"); tree.startContent(); buildMarkLogicPairs(tree, (JSONObject) json); } else if (json instanceof JSONArray) { tree.addAttribute(_type, "array"); tree.startContent(); buildMarkLogicArray(tree, (JSONArray) json); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) { tree.addAttribute(_type, "number");
if (name != null) { tree.addAttribute(_name, name); } tree.startContent(); buildJsonXPairs(tree, (JSONObject) json); tree.addEndElement(); } else if (json instanceof JSONArray) { if (name != null) { tree.addAttribute(_name, name); } tree.startContent(); buildJsonXArray(tree, (JSONArray) json); tree.addEndElement(); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) {
tree.addStartElement(jx_object); tree.startContent(); buildJxmlPairs(tree, (JSONObject) json); tree.addEndElement(); } else if (json instanceof JSONArray) { tree.addStartElement(jx_array); tree.startContent(); buildJxmlArray(tree, (JSONArray) json); tree.addEndElement(); } else if (json instanceof Integer || json instanceof Double || json instanceof Long) {