File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -326,7 +326,7 @@ public double getDouble(int index) throws JSONException {
326326 public float getFloat (int index ) throws JSONException {
327327 final Object object = this .get (index );
328328 if (object instanceof Number ) {
329- return ((Float )object ).floatValue ();
329+ return ((Number )object ).floatValue ();
330330 }
331331 try {
332332 return Float .parseFloat (object .toString ());
Original file line number Diff line number Diff line change @@ -364,6 +364,8 @@ public void getArrayValues() {
364364 new Double (23.45e-4 ).equals (jsonArray .getDouble (5 )));
365365 assertTrue ("Array string double" ,
366366 new Double (23.45 ).equals (jsonArray .getDouble (6 )));
367+ assertTrue ("Array double can be float" ,
368+ new Float (23.45e-4f ).equals (jsonArray .getFloat (5 )));
367369 // ints
368370 assertTrue ("Array value int" ,
369371 new Integer (42 ).equals (jsonArray .getInt (7 )));
You can’t perform that action at this time.
0 commit comments