elasticsearch - From Json String to XContentBuilder -
i have file in json format, there way convert xcontentbuilder?
what want read file mapping , convert xcontentbuilder
something like:
xcontentbuilder builder = jsonxcontent.contentbuilder().source(string json);
this seems work me:
import static org.elasticsearch.common.xcontent.xcontentfactory.jsonbuilder; import org.elasticsearch.common.xcontent.xcontentbuilder; import org.elasticsearch.common.xcontent.xcontentfactory; import org.elasticsearch.common.xcontent.xcontentparser; import org.elasticsearch.common.xcontent.xcontenttype; ... string message = "{\"bob\": \"test\"}"; xcontentparser parser = xcontentfactory.xcontent(xcontenttype.json).createparser(message.getbytes(); parser.close(); xcontentbuilder builder = jsonbuilder().copycurrentstructure(parser);
Comments
Post a Comment