title: JSONObject not a String Error
body: <pre><code>    {
    "query": {
      "count": 1,
      "created": "2015-07-28T05:19:01Z",
      "lang": "en-US",
      "results": {
        "quote": {
          "symbol": "GITANJALI.NS",
          "Ask": null,
          "AverageDailyVolume": null,
          "Bid": null,
          "AskRealtime": null,
          "BidRealtime": null,
          "BookValue": null,
          "Change_PercentChange": null,
          "Change": null,
          "Commission": null,
          "Currency": null,
          "ChangeRealtime": null,
          "AfterHoursChangeRealtime": null,
          "DividendShare": null,
          "LastTradeDate": null,
          "TradeDate": null,
          "EarningsShare": "9.73",
          "ErrorIndicationreturnedforsymbolchangedinvalid": null,
          "EPSEstimateCurrentYear": null,
          "EPSEstimateNextYear": null,
          "EPSEstimateNextQuarter": null,
          "DaysLow": null,
          "DaysHigh": null,
          "YearLow": null,
          "YearHigh": null,
          "HoldingsGainPercent": null,
          "AnnualizedGain": null,
          "HoldingsGain": null,
          "HoldingsGainPercentRealtime": null,
          "HoldingsGainRealtime": null,
          "MoreInfo": null,
          "OrderBookRealtime": null,
          "MarketCapitalization": null,
          "MarketCapRealtime": null,
          "EBITDA": null,
          "ChangeFromYearLow": null,
          "PercentChangeFromYearLow": null,
          "LastTradeRealtimeWithTime": null,
          "ChangePercentRealtime": null,
          "ChangeFromYearHigh": null,
          "PercebtChangeFromYearHigh": null,
          "LastTradeWithTime": null,
          "LastTradePriceOnly": null,
          "HighLimit": null,
          "LowLimit": null,
          "DaysRange": null,
          "DaysRangeRealtime": null,
          "FiftydayMovingAverage": null,
          "TwoHundreddayMovingAverage": null,
          "ChangeFromTwoHundreddayMovingAverage": null,
          "PercentChangeFromTwoHundreddayMovingAverage": null,
          "ChangeFromFiftydayMovingAverage": null,
          "PercentChangeFromFiftydayMovingAverage": null,
          "Name": null,
          "Notes": null,
          "Open": null,
          "PreviousClose": null,
          "PricePaid": null,
          "ChangeinPercent": null,
          "PriceSales": null,
          "PriceBook": null,
          "ExDividendDate": null,
          "PERatio": null,
          "DividendPayDate": null,
          "PERatioRealtime": null,
          "PEGRatio": null,
          "PriceEPSEstimateCurrentYear": null,
          "PriceEPSEstimateNextYear": null,
          "Symbol": "GITANJALI.NS",
          "SharesOwned": null,
          "ShortRatio": null,
          "LastTradeTime": null,
          "TickerTrend": null,
          "OneyrTargetPrice": null,
          "Volume": null,
          "HoldingsValue": null,
          "HoldingsValueRealtime": null,
          "YearRange": null,
          "DaysValueChange": null,
          "DaysValueChangeRealtime": null,
          "StockExchange": null,
          "DividendYield": null,
          "PercentChange": null
        }
      }
    }
  }
  </code></pre>
  
  <p>This is the Json I'm getting and I'm trying to get <strong>MarketCapitalization</strong> out of this using:</p>
  
  <pre><code>import org.json.JSONArray;
  import org.json.JSONObject;
  </code></pre>
  
  <p>by doing following operation:</p>
  
  <pre><code>String marketCap = obj.getJSONObject("query").getJSONObject("results")
                  .getJSONObject("quote").getString("MarketCapitalization");
  </code></pre>
  
  <p>but I'm getting following error</p>
  
  <pre><code>org.json.JSONException: JSONObject["MarketCapitalization"] not a string.
      at org.json.JSONObject.getString(JSONObject.java:658)
      at com.mobileforce.YahooClient.prepareReadCompany(YahooClient.java:136)
      at com.mobileforce.YahooClient.read(YahooClient.java:82)
      at com.mobileforce.YahooClient.handleApi(YahooClient.java:42)
      at com.mobileforce.YahooServlet.doPost(YahooServlet.java:44)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p><strong>Note: If in case MarketCapitalization has some value then the above is working completely fine. The problem is occurring only when it is null</strong> </p>