title: Getting Json object inside a Json object in Java
body: <p>So I have some code that is able to send this out:</p>
  
  <pre><code>  {"id":1,
     "method":"addWaypoint",
     "jsonrpc":"2.0",
     "params":[
       {
         "lon":2,
         "name":"name",
         "lat":1,
         "ele":3
       }
      ]
     }
  </code></pre>
  
  <p>The server receives this JSON object as a string named "clientstring":</p>
  
  <pre><code> JSONObject obj = new JSONObject(clientstring); //Make string a JSONObject
   String method = obj.getString("method"); //Pulls out the corresponding method
  </code></pre>
  
  <p>Now, I want to be able to get the "params" value of {"lon":2,"name":"name","lat":1,"ele":3} just like how I got the "method".
  however both of these have given me exceptions: </p>
  
  <pre><code>String params = obj.getString("params");
  </code></pre>
  
  <p>and</p>
  
  <pre><code> JSONObject params = obj.getJSONObject("params");
  </code></pre>
  
  <p>I'm really at a loss how I can store and use {"lon":2,"name":"name","lat":1,"ele":3} without getting an exception, it's legal JSON yet it can't be stored as an JSONObject? I dont understand.</p>
  
  <p>Any help is VERY appreciated, thanks!</p>