public <T> T fromJson(String json, Class<T> clazz) {
        if (json == null || json.trim().length() == 0) {
            return null;
        }

        try {
            return mapper.readValue(json, clazz);
        } catch (IOException e) {
            logger.warn("fromJson出错:" + json, e);
            return null;
        }
    }
public < T > T fromJson ( String json , Class < T > clazz ) { if ( json == null || json . trim ( ) . length ( ) == 0 ) { return null ; } try { return mapper . readValue ( json , clazz ) ; } catch ( IOException e ) { logger . warn ( "fromJson出错:" + json , e ) ; return null ; } }
JSON转换成Java对象

@param json
@param clazz
@param <T>
@return