Why is GSON putting a decimal point and zero after all my JSON numbers that initially do not contain decimal numbers?

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);
    }
+4
source share
1 answer

From Wikipedia. The main types of JSON:

- , E. JSON NaN, . ( , JavaScript , JSON -)

int float. , , , String, . Integer.

+1

Source: https://habr.com/ru/post/1545083/


All Articles