处理浮点型参数
This commit is contained in:
parent
d9672cd75a
commit
81891e97c9
@ -100,9 +100,16 @@ public class JcPrinter extends CordovaPlugin {
|
||||
JSONArray methodJsonArgs = args.getJSONArray(1);
|
||||
Object[] methodArgs = new Object[methodJsonArgs.length()];
|
||||
for(int i=0;i<methodJsonArgs.length();i++){
|
||||
Object obj = methodJsonArgs.opt(i);
|
||||
Class<?> a = m.getParameterTypes()[i];
|
||||
Object obj = null;
|
||||
if(a == Float.class){
|
||||
obj = Float.parseFloat(methodJsonArgs.optString(i));
|
||||
} else if(a == Integer.class){
|
||||
obj = methodJsonArgs.optInt(i);
|
||||
} else{
|
||||
obj = methodJsonArgs.opt(i);
|
||||
}
|
||||
if(obj instanceof JSONArray){
|
||||
Class<?> a = m.getParameterTypes()[i].getComponentType();
|
||||
Object array = Array.newInstance(a,((JSONArray) obj).length());
|
||||
for(int j=0;j<((JSONArray) obj).length();j++){
|
||||
Array.set(array,j,((JSONArray) obj).opt(j));
|
||||
|
Loading…
x
Reference in New Issue
Block a user