/** * Assigns a JSON tree as the content and returns the handle. * @param content the JSON root node. * @return the handle on the JSON tree. */ public JacksonHandle with(JsonNode content) { set(content); return this; }
ObjectMapper objM = new ObjectMapper(); JsonNode jn = objM.readTree(new String("{\"animal\":\"dog\", \"says\":\"woof\"}")); jh.set(jn); jh.setFormat(Format.JSON);
/** * Provides a handle on JSON content as a Jackson tree. * @param content the JSON root node of the tree. */ public JacksonHandle(JsonNode content) { this(); set(content); }
ObjectMapper objM = new ObjectMapper(); JsonNode jn = objM.readTree(new String("{\"animal\":\"dog\", \"says\":\"woof\"}")); jh.set(jn); jh.setFormat(Format.JSON);
@Override protected void receiveContent(InputStream content) { if (content == null) return; try { set( getMapper().readValue( new InputStreamReader(content, "UTF-8"), JsonNode.class )); } catch (JsonParseException e) { throw new MarkLogicIOException(e); } catch (JsonMappingException e) { throw new MarkLogicIOException(e); } catch (IOException e) { throw new MarkLogicIOException(e); } finally { try { content.close(); } catch (IOException e) { // ignore. } } } @Override
ObjectMapper objM = new ObjectMapper(); JsonNode jn = objM.readTree(new String("{\"animal\":\"dog\", \"says\":\"woof\"}")); jh.set(jn); jh.setFormat(Format.JSON);
public void loadJSONDocuments() throws KeyManagementException, NoSuchAlgorithmException, JsonProcessingException, IOException { int count = 1; JSONDocumentManager docMgr = client.newJSONDocumentManager(); DocumentWriteSet writeset = docMgr.newWriteSet(); Map<String, String> map = new HashMap<>(); for (int i = 0; i < 102; i++) { JsonNode jn = new ObjectMapper().readTree("{\"animal\":\"dog " + i + "\", \"says\":\"woof\"}"); JacksonHandle jh = new JacksonHandle(); jh.set(jn); writeset.add(DIRECTORY + "dog" + i + ".json", jh); map.put(DIRECTORY + "dog" + i + ".json", jn.toString()); if (count % BATCH_SIZE == 0) { docMgr.write(writeset); writeset = docMgr.newWriteSet(); } count++; // System.out.println(jn.toString()); } if (count % BATCH_SIZE > 0) { docMgr.write(writeset); } }
public void loadJSONDocuments() throws KeyManagementException, NoSuchAlgorithmException, JsonProcessingException, IOException { int count = 1; JSONDocumentManager docMgr = client.newJSONDocumentManager(); DocumentWriteSet writeset = docMgr.newWriteSet(); Map<String, String> map = new HashMap<>(); for (int i = 0; i < 102; i++) { JsonNode jn = new ObjectMapper().readTree("{\"animal\":\"dog" + i + "\", \"says\":\"woof\"}"); JacksonHandle jh = new JacksonHandle(); jh.set(jn); writeset.add(DIRECTORY + "dog" + i + ".json", jh); map.put(DIRECTORY + "dog" + i + ".json", jn.toString()); if (count % BATCH_SIZE == 0) { docMgr.write(writeset); writeset = docMgr.newWriteSet(); } count++; // System.out.println(jn.toString()); } if (count % BATCH_SIZE > 0) { docMgr.write(writeset); } }
public void loadJSONDocuments() throws KeyManagementException, NoSuchAlgorithmException, JsonProcessingException, IOException { int count = 1; JSONDocumentManager docMgr = client.newJSONDocumentManager(); DocumentWriteSet writeset = docMgr.newWriteSet(); Map<String, String> map = new HashMap<>(); for (int i = 0; i < 102; i++) { JsonNode jn = new ObjectMapper().readTree("{\"animal\":\"dog" + i + "\", \"says\":\"woof\"}"); JacksonHandle jh = new JacksonHandle(); jh.set(jn); writeset.add(DIRECTORY + "dog" + i + ".json", jh); map.put(DIRECTORY + "dog" + i + ".json", jn.toString()); if (count % BATCH_SIZE == 0) { docMgr.write(writeset); writeset = docMgr.newWriteSet(); } count++; // System.out.println(jn.toString()); } if (count % BATCH_SIZE > 0) { docMgr.write(writeset); } }
ObjectNode mainNode = mapper.createObjectNode(); mainNode.set("query", queryArrayNode); jh.set(mainNode); RawStructuredQueryDefinition qd = queryMgr.newRawStructuredQueryDefinition(jh); System.out.println(jh.get().toString());
jh.set(jh2.getMapper().readTree(tjs.getJSON("helloJS0.json"))); jh.set(jh2.getMapper().readTree(tjs.getJSON("helloJS" + j + ".json"))); JSONAssert.assertEquals(expAftrPut, jh.get().get("document-content").findParent("array").toString(), false); JSONAssert.assertEquals(expectedResponse, tjs.deleteJSON("helloJS" + j + ".json"), false);
JsonNode jn = new ObjectMapper().readTree("{\"animal" + i + "\":\"dog" + i + "\", \"says\":\"woof\"}"); JacksonHandle jh = new JacksonHandle(); jh.set(jn); writeset.add(DIRECTORY + "dog" + i + ".json", jh); map.put(DIRECTORY + "dog" + i + ".json", jn.toString());
JsonNode jn = new ObjectMapper().readTree("{\"animal" + i + "\":\"dog" + i + "\", \"says\":\"woof\"}"); JacksonHandle jh = new JacksonHandle(); jh.set(jn); writeset.add(DIRECTORY + j + "/cm-dog" + i + ".json", jh); map.put(DIRECTORY + j + "/cm-dog" + i + ".json", jn.toString());
JacksonHandle writeHandle = new JacksonHandle(); JsonNode writeDocument = writeHandle.getMapper().convertValue(product1, JsonNode.class); writeHandle.set(writeDocument); JsonNode writeDocument2 = writeHandle.getMapper().convertValue(product2, JsonNode.class); JsonNode writeDocument3 = writeHandle.getMapper().convertValue(product3, JsonNode.class);
writeHandle.set(writeDocument); JsonNode writeDocument2 = writeHandle.getMapper().convertValue(product2, JsonNode.class); JsonNode writeDocument3 = writeHandle.getMapper().convertValue(product3, JsonNode.class);