Retrieving values back from XContentBuilder objects

Hey all,

This is kind of a silly question, but I haven't seen this mentioned anywhere and haven't been able to get it working on my own. If I create an XContentBuilder object, is it possible to retrieve values from that object?

Say I have:
val foo = jsonBuilder().startObject().field("foo", "bar").endObject()

Is it possible to retrieve foo's bar value without having to convert foo to a string and then parsing the JSON again?


XContentBuilder says it all. It's a builder, not a parser.

In XContentHelper, there is a helper method copyCurrentStructure for
copying a builder (generator) into a parser, so you can skip the string


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit