【发布时间】:2017-05-14 11:52:21
【问题描述】:
解析对象后,字符串值会自动更改为双精度值。 任何相同的解决方法
JSONObject elementInfo = obj.getElementInfo();
System.out.println("get elementInfo ---> "+elementInfo.get("info"));
//mapping
ArrayList<Object> getEle = gson.fromJson((String) elementInfo.get("info"), ArrayList.class);
System.out.println("After mapping getele----> "+getEle);
结果
get elementInfo ---> [{noOfBins=2, indices=[1, 3]}, {noOfBins=3, indices=[2]}]
After mapping getele----> [{noOfBins=2.0, indices=[1.0, 3.0]}, {noOfBins=3.0, indices=[2.0]}]
即使在映射之后,我将如何获得确切的值? 需要得到它作为
[{noOfBins=2, indices=[1, 3]}, {noOfBins=3, indices=[2]}]
【问题讨论】:
-
我在您的
elementInfoJson 中看不到任何字符串。 JSON 中的字符串类似于"2"或'2',没有引号,这是一个数字
标签: java object arraylist gson