I have a two json objects
JSONObject org_query = new JSONObject("{\"query\": {\"bool\": {\"must\": [], \"must_not\": [], \"should\": []}}}");
JSONObject query_form = new JSONObject("{\"match_phrase\": {\"Sales Channel\": \"Online\"}}");
I want to append the second object to first one inside the key must
and form a new JSON object.
Required Output:
{"query":{"bool":{"must_not":[],"should":[],"must":[{"match_phrase": {"Sales Channel": "Online"}}]}}}
I tried this,
org_query["query"]["bool"]["must"].append(query_form);
But shows error.
array type expected found org.json.jsonarray java
How to make it