使用Jackson将科学记数法中的数字转换为Double

时间:2018-01-30 15:56:38

标签: java json jackson scientific-notation

杰克逊版本:2.0.2

 String jsonString = "{\"data\":10000000.00, \"data2\" : 0E-7}";
 ObjectMapper mapper =  new ObjectMapper();
 mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
 JsonNode jsonNode = mapper.readTree(jsonString);
 System.out.println(jsonNode.toString());
 System.out.println(new ObjectMapper().readTree(jsonString));

我收到以下回复

{"data":10000000.00,"data2":0E-7}
{"data":1.0E7,"data2":0.0}

我能做些什么来获得输出 { “数据”:10000000.00,“数据2” :0.0}

0 个答案:

没有答案