处理数组中的浮点型
This commit is contained in:
parent
eba70ffe77
commit
bbb5dab3e2
@ -110,9 +110,18 @@ public class JcPrinter extends CordovaPlugin {
|
|||||||
obj = methodJsonArgs.opt(i);
|
obj = methodJsonArgs.opt(i);
|
||||||
}
|
}
|
||||||
if(obj instanceof JSONArray){
|
if(obj instanceof JSONArray){
|
||||||
Object array = Array.newInstance(a.getComponentType(),((JSONArray) obj).length());
|
a = a.getComponentType();
|
||||||
|
Object array = Array.newInstance(a,((JSONArray) obj).length());
|
||||||
for(int j=0;j<((JSONArray) obj).length();j++){
|
for(int j=0;j<((JSONArray) obj).length();j++){
|
||||||
Array.set(array,j,((JSONArray) obj).opt(j));
|
Object innerObj;
|
||||||
|
if(a == Float.class){
|
||||||
|
innerObj = Float.parseFloat(((JSONArray) obj).optString(j));
|
||||||
|
} else if(a == Integer.class){
|
||||||
|
innerObj = ((JSONArray) obj).optInt(j);
|
||||||
|
} else{
|
||||||
|
innerObj = ((JSONArray) obj).opt(j);
|
||||||
|
}
|
||||||
|
Array.set(array,j,innerObj);
|
||||||
}
|
}
|
||||||
methodArgs[i] = array;
|
methodArgs[i] = array;
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
Reference in New Issue
Block a user