Created
June 25, 2016 16:05
-
-
Save noctarius/33adc963f7799018bd0d94d13d3ef5ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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