### Question:
StreamJsonParser { public boolean parse() throws IOException, JsonProcessingException { JsonParser parser=factory.createParser(input); boolean done=false; do { TreeNode t=parser.readValueAsTree(); if(t==null) { done=true; } else { if(t instanceof ObjectNode) { if(!documentCompleted((ObjectNode)t)) return false; } else if(t instanceof ArrayNode) { int n=t.size(); for(int i=0;i<n;i++) { TreeNode elem=t.path(i); if(elem!=null) { if(!documentCompleted((ObjectNode)elem)) return false; } } } else { throw new RuntimeException("Ill formed stream"); } } } while(!done); return true; } StreamJsonParser(InputStream input);  StreamJsonParser(InputStream input,ObjectMapper mapper); boolean parse(); boolean documentCompleted(ObjectNode n);  }### Answer:
@Test public void testSingleObj() throws Exception { ObjectNode n=JsonNodeFactory.instance.objectNode(); n.set("field",JsonNodeFactory.instance.textNode("value")); String json=n.toString(); System.out.println("Parse "+json); TestStreamJsonParser parser=new TestStreamJsonParser(new StringBufferInputStream(json)); parser.parse(); Assert.assertEquals(1,parser.nodes.size()); Assert.assertEquals("value",parser.nodes.get(0).get("field").asText()); }
@Test public void testMultipleObj() throws Exception { ObjectNode n1=JsonNodeFactory.instance.objectNode(); n1.set("field",JsonNodeFactory.instance.textNode("value")); ObjectNode n2=JsonNodeFactory.instance.objectNode(); n2.set("field2",JsonNodeFactory.instance.textNode("value2")); String json=n1+" "+n2; System.out.println("Parse "+json); TestStreamJsonParser parser=new TestStreamJsonParser(new StringBufferInputStream(json)); parser.parse(); Assert.assertEquals(2,parser.nodes.size()); Assert.assertEquals("value",parser.nodes.get(0).get("field").asText()); Assert.assertEquals("value2",parser.nodes.get(1).get("field2").asText()); }