title: How to decode JSONObject
body: <p>This question is related with my previous <a href="https://stackoverflow.com/questions/27577922/how-to-pass-a-json-array-as-a-parameter-in-url">question</a></p>
  
  <p>I can successfully get the String in json format from the URL to my spring controller</p>
  
  <p>Now I have to decode it</p>
  
  <p>so I did like the following</p>
  
  <pre><code>@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();
  }
  </code></pre>
  
  <p>This is the JSON String <code>{ "nameservice": [ { "id": 7413, "name": "ask" }, { "id": 7414, "name": "josn" }, { "id": 7415, "name": "john" }, { "id": 7418, "name": "RjhjhjR" } ] }</code></p>
  
  <p>When I run the code then I get the error</p>
  
  <pre><code>org.json.JSONException: JSONObject["nameservice"] is not a JSONObject.
  </code></pre>
  
  <p>What wrong I am doing?</p>