I am having issues parsing my integer values from JSON to String so I can add it to an array list.
I have tried using Integer.valueOf but I am a bit stuck on the formatting for this particular issue and whether Integer.valueOf will actually work or not.
This is the code I have that works so far
try {
JSONArray jsonArray = new JSONArray(response);
vehicleMakes = new String[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) {
String make = jsonArray.getJSONObject(i).get("make").toString();
String model = jsonArray.getJSONObject(i).get("model").toString();
String reg = jsonArray.getJSONObject(i).get("license_number").toString();
// int year = jsonArray.getJSONObject(i).get("year").toString();
Vehicle V = new Vehicle(make, model, reg);
vehicleArrayList.add(V);
}
}
catch (JSONException e) {
e.printStackTrace();
}
I am trying to add integer variables with this, such as
int year = jsonArray.getJSONObject(i).get("year").toString();
How can I add this?