This question is related with my previous question
I can successfully get the String in json format from the URL to my spring controller
Now I have to decode it
so I did like the following
@RequestMapping("/saveName")
@ResponseBody
public String saveName(String acc)
{jsonObject = new JSONObject();
    try
    {
   System.out.println(acc);
    org.json.JSONObject convertJSON=new org.json.JSONObject(acc);
    org.json.JSONObject  newJSON = convertJSON.getJSONObject("nameservice");
    System.out.println(newJSON.toString());
    convertJSON = new org.json.JSONObject(newJSON.toString());
    System.out.println(jsonObject.getString("id"));
    }
    catch(Exception e)
    {
        e.printStackTrace();jsonObject.accumulate("result", "Error Occured ");
    }
    return jsonObject.toString();
}
This is the JSON String { "nameservice": [ { "id": 7413, "name": "ask" }, { "id": 7414, "name": "josn" }, { "id": 7415, "name": "john" }, { "id": 7418, "name": "RjhjhjR" } ] }
When I run the code then I get the error
org.json.JSONException: JSONObject["nameservice"] is not a JSONObject.
What wrong I am doing?
 
     
     
     
    