gson Float.POSITIVE_INFINITY nan问题

gson无法解析 Float.NaN

NaN is not a valid double value as per JSON specification

 

如何解决:

1)在服务端把Map> 改为Map返回这个值

2)在客户端android

public void onResponse(Call> call, Response> response)

map.put("mapData",response.body());

3)对其解析
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.serializeSpecialFloatingPointValues();
        Gson gson = gsonBuilder.create();

        Map body = (Map) mapData.get("mapData");

String strPoints = mapData.get(aaa);
        List points = gson.fromJson(strPoints, new TypeToken>(){}.getType());

 

你可能感兴趣的:(android)