Object convertArgument ( String arg , Type paramType ) throws IllegalArgumentException { Object result = null ; if ( null == arg || "null" . equals ( arg ) ) { return result ; } logger . debug ( "Try to convert {} : param = {} : {}" , new Object [ ] { arg , paramType , paramType . getClass ( ) } ) ; try { // GenericArrayType, ParameterizedType, TypeVariable<D>, WildcardType, Class if ( ParameterizedType . class . isInstance ( paramType ) ) { JavaType javaType = getJavaType ( paramType ) ; logger . debug ( "Try to convert '{}' to JavaType : '{}'", rg, aramType) ; result = getObjectMapper ( ) . readValue ( arg , javaType ) ; logger . debug ( "Conversion of '{}' to '{}' : OK", rg, aramType) ; } else if ( Class . class . isInstance ( paramType ) ) { Class cls = ( Class ) paramType ; logger . debug ( "Try to convert '{}' to Class '{}'" , arg , paramType ) ; checkStringArgument ( cls , arg ) ; result = getObjectMapper ( ) . readValue ( arg , cls ) ; logger . debug ( "Conversion of '{}' to '{}' : OK", rg, aramType) ; } else { // GenericArrayType, TypeVariable<D>, WildcardType logger . warn ( "Conversion of '{}' to '{}' not yet supported", rg, aramType) ; } } catch ( IOException ex ) { logger . debug ( "Conversion of '{}' to '{}' failed" , arg , paramType ) ; throw new IllegalArgumentException ( paramType . toString ( ) ) ; } return result ; }
try to convert json argument in java type