I need to convert String object to Json object in spring boot
i have coded like this but through error
public Map<String, Object> datesearch() throws IOException
{
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("check1");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.rangeQuery("date").from("2019-10-01").to("2019-10-03"));
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
XContentBuilder builder = XContentFactory.jsonBuilder();
searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
JSONObject json = new JSONObject(builder.toString()); // error at this line
return json;
}