What I understand from the docu it is possible to use one XContentBuilder for the content of another XContentBuilder.
You can directly pass numbers, dates and even other XContentBuilder objects.
How to do that?
What I tried was for example:
jsonBuilder().startObject(new XContentBuilderString(CustomInnerXContentBuilder().string())).endObject();
public XContentBuilder CustomInnerXContentBuilder() throws IOException {
return jsonBuilder().startObject("test").endObject();
}
The outcome is quotes are escaped and newlines are "\n" - which is not desired. (Furthermore I added the XContentBuilderString via an additional object, which is also not desired.)
e.g. outcome:
""test"{}" : { }
but I want
"test"{}
Sidenote: Elasticsearch Java API version 2.2.0