title: Parsing response from Api - Data returned is seen as double and Integer - How to Parse
body: <p>The API returns either a whole number like = 129
  or A decimal for example 0.28 
  Here is the response from API:</p>
  
  <pre><code>"ETH":{"USD":730.06}"
  </code></pre>
  
  <p>I'm trying to parse the JSON
  with the following:</p>
  
  <pre><code>Double ethPrice = (double) arr.get("USD");
  </code></pre>
  
  <p>Which works if the data returned is a number with a decimal but if it is a whole number then I'm getting:</p>
  
  <pre><code>java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
  </code></pre>
  
  <p>I'm not doing any mathematical function with the response, therefore, a string type would work too. </p>
  
  <p>I feel like it is a small problem I should have solved already. But spent a bit of time on it now and don't want to waste anymore. 
  Any help would be great.</p>
  
  <p>Edit : </p>
  
  <p>Request code snippet of parsing:</p>
  
  <pre><code>JSONObject obj = new JSONObject(result);
  JSONObject arr = obj.getJSONObject("ETH");
  Double ethPrice = (double) arr.get("USD");
  </code></pre>
  
  <p>Where result is a string (inside async task - onPostExecute(String result)) </p>