Skip to content

Instantly share code, notes, and snippets.

@noctarius
Created June 25, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noctarius/33adc963f7799018bd0d94d13d3ef5ec to your computer and use it in GitHub Desktop.
Save noctarius/33adc963f7799018bd0d94d13d3ef5ec to your computer and use it in GitHub Desktop.
StreamWriter streamWriter = StreamWriter.newBuilder().build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamGraphBuilder graphBuilder = streamWriter.newStreamGraphBuilder(Output.toOutputStream(baos));
graphBuilder.putNumber(100).putNumber(101).putNumber(102).putNumber(103).putNumber(104).finishStream();
Parser parser = Parser.newBuilder().build();
Input input = Input.fromByteArray(baos.toByteArray());
// Dictionary, inner dictionary, inner sequence
String queryString = "(a: #0, b: #0, c: (d: #0, e: #0), f: #4, g: (#0, #1, #2))";
GraphQuery query = parser.prepareQuery(queryString);
Value value = parser.read(input, query);
System.out.println(ValuePrettyPrinter.asStringPrettyPrint(value1));
/**
* Result:
* Dictionary [
* TextString{ b }=UInt{ 100 },
* TextString{ f }=UInt{ 104 },
* TextString{ g }=Sequence [
* UInt{ 100 },
* UInt{ 101 },
* UInt{ 102 }
* ],
* TextString{ a }=UInt{ 100 },
* TextString{ c }=Dictionary [
* TextString{ d }=UInt{ 100 },
* TextString{ e }=UInt{ 100 }
* ]
* ]
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment