From the below JSON, I want to display the Query string. I have done it by using JSON parser.
{
"group By": "name",
"time Period": {
"from": "2015-12-29",
"to": "2016-02-29"
},
"query String": "[nation]: \"India\" AND [education]: \"be",
"geography": "NA",
"offset": 0,
"limit": 10
}
While running, it shows error as
Exception in thread "main" org.json.JSONException: JSONObject["query String"] is not a JSONObject.
My JSON query is:
String request = rs.getString("Request");
JSONObject jsonObject = new JSONObject(request);
JSONObject newJSON = jsonObject.getJSONObject("groupBy");
String input = newJSON.toString();
query Stringat all - although it does ask forgroupByas if it were a JSON object, which it's not, and by the wrong name. The code you've given doesn't match the error you've shown. Please provide a minimal reproducible example.