@@ -83,7 +83,14 @@ public String outputResult() throws InvocationTargetException, IllegalAccessExce
8383 convertedParams [i ] = Integer .valueOf (inputVal [i ]);
8484 } else if (genericParameterTypes [i ] == String .class ) {
8585 convertedParams [i ] = inputVal [i ];
86- } else if (genericParameterTypes [i ] == Object [].class || genericParameterTypes [i ] == String [].class ) {
86+ } else if (genericParameterTypes [i ] == Object [].class ) {
87+ String [] remainingArgs = Arrays .copyOfRange (inputVal , i , inputVal .length );
88+ Object [] convertedArray = new Object [remainingArgs .length ];
89+ for (int j = 0 ; j < remainingArgs .length ; j ++) {
90+ convertedArray [j ] = smartConvertValue (remainingArgs [j ]);
91+ }
92+ convertedParams [i ] = convertedArray ;
93+ } else if (genericParameterTypes [i ] == String [].class ) {
8794 convertedParams [i ] = Arrays .copyOfRange (inputVal , i , inputVal .length );
8895 } else if (genericParameterTypes [i ] == String [][].class ) {
8996 String [] arr = Arrays .copyOfRange (inputVal , i , inputVal .length );
@@ -148,4 +155,34 @@ public String outputResult() throws InvocationTargetException, IllegalAccessExce
148155 ObjectMapper mapper = new ObjectMapper ();
149156 return mapper .writeValueAsString (responseBody );
150157 }
158+
159+ /**
160+ * @param value
161+ * @return
162+ */
163+ private Object smartConvertValue (String value ) {
164+ if (value == null || value .trim ().isEmpty ()) {
165+ return value ;
166+ }
167+
168+ String trimmed = value .trim ();
169+
170+ try {
171+ return Integer .valueOf (trimmed );
172+ } catch (NumberFormatException e ) {
173+ }
174+
175+ if ("true" .equalsIgnoreCase (trimmed )) {
176+ return Boolean .TRUE ;
177+ } else if ("false" .equalsIgnoreCase (trimmed )) {
178+ return Boolean .FALSE ;
179+ }
180+
181+ try {
182+ return Double .valueOf (trimmed );
183+ } catch (NumberFormatException e ) {
184+ }
185+
186+ return value ;
187+ }
151188}
0 commit comments