title: JSONObject["locationInfo"] not a string
body: <p>Sorry for the repeated question.I have been banging my head on this since hours.
  I am trying to parse json to an object of setter/getter class.</p>
  
  <pre><code>String location = request.getParameter("location");
  System.out.print(location);
  
  org.json.JSONObject json = new org.json.JSONObject(location);
  /* JSONObject js = json.getJSONObject("locationInfo");
  String mapLoc = js.getString("locationInfo"); */
  String mapLoc = json.getString("locationInfo");  &lt;--- receiving the error on this line
  
  Gson gsn = new Gson();
  MapObject mLocObj = gsn.fromJson(mapLoc, MapObject.class);
  System.out.println(mLocObj.getLongitude());
  double longitude = Double.parseDouble(mLocObj.getLongitude());
  double latitude = Double.parseDouble(mLocObj.getLatitude());
  </code></pre>
  
  <p>Here is my json string location:</p>
  
  <pre><code>{"locationInfo":{"latitude":"19.3828815","longitude":"72.8296205"}}
  </code></pre>
  
  <p>This is the error log:</p>
  
  <pre><code>19: System.out.print(location);
  20: 
  21: org.json.JSONObject json = new org.json.JSONObject(location);
  22: String mapLoc = json.getString("locationInfo");
  23: 
  24:     Gson gsn = new Gson();
  25:     MapObject mLocObj = gsn.fromJson(mapLoc, MapObject.class);
  
  
  Stacktrace:] with root cause
  org.json.JSONException: JSONObject["locationInfo"] not a string.
  at org.json.JSONObject.getString(JSONObject.java:639)
  at org.apache.jsp.mapView_jsp._jspService(mapView_jsp.java:88)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  at       org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
  at java.lang.Thread.run(Thread.java:619)
  </code></pre>