@Override public void write(OutputStream out) throws IOException { getMapper().writeValue(new OutputStreamWriter(out, "UTF-8"), get()); } }
@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
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);
@Test public void test105Searches() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (int i=0;i<105;i++) { for (QueryDefinition t : new QueryDefinition[] { qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { JacksonHandle results = queryMgr.search(t, new JacksonHandle()); assertNotNull(results); JsonNode jsonResults =results.get(); @SuppressWarnings("unused") String resultString = results.getMapper().writeValueAsString(jsonResults); // ignore. } } }
product3.setDescription("Very cool Ipod"); 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); JSONDocumentManager docMgr = client.newJSONDocumentManager(); DocumentWriteSet writeset = docMgr.newWriteSet();
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); JSONDocumentManager docMgr = client.newJSONDocumentManager(); DocumentWriteSet writeset = docMgr.newWriteSet();