I read JSON from a web service and converted all JSON objects HashMap<String, String>to using GSON.
I tested, and my JSONObject is fine (without a decimal point in any of the numbers), but the map object has elements with all numbers with a decimal point and zero after that.
Here is my code:
try {
jsonArray = json.getJSONArray("PropertyListings");
for(int i = 0; i < jsonArray.length(); i++){
JSONObject c = jsonArray.getJSONObject(i);
HashMap<String, String> map = new HashMap<String, String>();
map = (HashMap<String, String>) new Gson().fromJson(jsonArray.getString(i), map.getClass());
listOfProperties.add(map);
}
source
share