File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
main/java/com/alibaba/fastjson
test/java/com/alibaba/json/bvt/bug Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ public double getDoubleValue(int index) {
314
314
return 0D ;
315
315
}
316
316
317
- return castToDouble (value ).floatValue ();
317
+ return castToDouble (value ).doubleValue ();
318
318
}
319
319
320
320
public BigDecimal getBigDecimal (int index ) {
Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ public double getDoubleValue(String key) {
247
247
return 0D ;
248
248
}
249
249
250
- return castToDouble (value ).floatValue ();
250
+ return castToDouble (value ).doubleValue ();
251
251
}
252
252
253
253
public BigDecimal getBigDecimal (String key ) {
Original file line number Diff line number Diff line change
1
+ package com .alibaba .json .bvt .bug ;
2
+
3
+ import junit .framework .Assert ;
4
+ import junit .framework .TestCase ;
5
+
6
+ import com .alibaba .fastjson .JSON ;
7
+ import com .alibaba .fastjson .JSONArray ;
8
+ import com .alibaba .fastjson .JSONObject ;
9
+
10
+
11
+ public class Bug_for_jiangwei1 extends TestCase {
12
+ public void test_double () throws Exception {
13
+ JSONObject json = JSON .parseObject ("{\" val\" :12.3}" );
14
+ Assert .assertEquals (12.3D , json .getDoubleValue ("val" ));
15
+ }
16
+
17
+ public void test_JSONArray_double () throws Exception {
18
+ JSONArray json = JSON .parseArray ("[12.3]" );
19
+ Assert .assertEquals (12.3D , json .getDoubleValue (0 ));
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments