Search in sources :

Example 1 with JSONVisitorCapture

use of com.ociweb.pronghorn.util.parse.JSONVisitorCapture in project PronghornPipes by oci-pronghorn.

the class JSONParserTest method arrayTest.

@Test
public void arrayTest() {
    String json = " [ { \"key\" : \"value\" } , \n { \"key\" : \"value\" }     ] ";
    Pipe pipe = buildPopulatedPipe(json);
    TrieParserReader reader = JSONParser.newReader();
    StringBuilder target = new StringBuilder();
    JSONVisitor visitor = new JSONVisitorCapture(target);
    int msgIdx = Pipe.takeMsgIdx(pipe);
    JSONParser.parse(pipe, reader, visitor);
    assertEquals("[{key:value},{key:value}]", target.toString());
}
Also used : JSONVisitor(com.ociweb.pronghorn.util.parse.JSONVisitor) JSONVisitorCapture(com.ociweb.pronghorn.util.parse.JSONVisitorCapture) Pipe(com.ociweb.pronghorn.pipe.Pipe) Test(org.junit.Test)

Example 2 with JSONVisitorCapture

use of com.ociweb.pronghorn.util.parse.JSONVisitorCapture in project PronghornPipes by oci-pronghorn.

the class JSONParserTest method simpleTest.

@Test
public void simpleTest() {
    String json = " { \"key\" : \"value\" }  ";
    Pipe pipe = buildPopulatedPipe(json);
    TrieParserReader reader = JSONParser.newReader();
    StringBuilder target = new StringBuilder();
    JSONVisitor visitor = new JSONVisitorCapture(target);
    int msgIdx = Pipe.takeMsgIdx(pipe);
    JSONParser.parse(pipe, reader, visitor);
    assertEquals("{key:value}", target.toString());
}
Also used : JSONVisitor(com.ociweb.pronghorn.util.parse.JSONVisitor) JSONVisitorCapture(com.ociweb.pronghorn.util.parse.JSONVisitorCapture) Pipe(com.ociweb.pronghorn.pipe.Pipe) Test(org.junit.Test)

Example 3 with JSONVisitorCapture

use of com.ociweb.pronghorn.util.parse.JSONVisitorCapture in project PronghornPipes by oci-pronghorn.

the class JSONParserTest method complexTest.

@Test
public void complexTest() {
    String json = " { \"key\" : \"value\" \n, \"key2\" : \"value2\"}  ";
    Pipe pipe = buildPopulatedPipe(json);
    TrieParserReader reader = JSONParser.newReader();
    StringBuilder target = new StringBuilder();
    JSONVisitor visitor = new JSONVisitorCapture(target);
    int msgIdx = Pipe.takeMsgIdx(pipe);
    JSONParser.parse(pipe, reader, visitor);
    assertEquals("{key:value,key2:value2}", target.toString());
}
Also used : JSONVisitor(com.ociweb.pronghorn.util.parse.JSONVisitor) JSONVisitorCapture(com.ociweb.pronghorn.util.parse.JSONVisitorCapture) Pipe(com.ociweb.pronghorn.pipe.Pipe) Test(org.junit.Test)

Aggregations

Pipe (com.ociweb.pronghorn.pipe.Pipe)3 JSONVisitor (com.ociweb.pronghorn.util.parse.JSONVisitor)3 JSONVisitorCapture (com.ociweb.pronghorn.util.parse.JSONVisitorCapture)3 Test (org.junit.Test)3