title: How do I parse JSON into an int?
body: <p>I have Parsed some JSON data and its working fine as long as I store it in String variables.</p>
  
  <p>My problem is that I need the ID in an int varibable and not in String.
  i have tried to make a cast <code>int id = (int) jsonObj.get("");</code></p>
  
  <p>But it gives an error message that I cannot convert an object to an int.
  So I tried to convert by using: </p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>String id = (String) jsonObj.get("id");
  int value = Integer.parseInt(id);
  </code></pre>
  
  <p>But also that is not working. What is wrong. How is JSON working with int?
  My strings are working just fine its only when I try to make them as an int I get problems.</p>
  
  <p>Here is my code :</p>
  
  <pre class="lang-java prettyprint-override"><code>public void parseJsonData() throws ParseException {
  
          JSONParser parser = new JSONParser();
          Object obj = parser.parse(jsonData);
          JSONObject topObject = (JSONObject) obj;
          JSONObject locationList = (JSONObject) topObject.get("LocationList");
          JSONArray array = (JSONArray) locationList.get("StopLocation");
          Iterator&lt;JSONObject&gt; iterator = array.iterator();
  
          while (iterator.hasNext()) {
  
              JSONObject jsonObj = (JSONObject) iterator.next();
              String name  =(String) jsonObj.get("name");
              String id = (String) jsonObj.get("id");
              Planner.getPlanner().setLocationName(name);
              Planner.getPlanner().setArrayID(id);
  
  
          }
  
      }
  </code></pre>