src/test/java/io/swagger/test/client/ApiClient.java
/**
     * Deserialize the given JSON string to Java object.
     *
     * @param json          The JSON string
     * @param containerType The container type, one of "list", "array" or ""
     * @param cls           The type of the Java object
     * @return The deserialized Java object
     */
Deserialize the given JSON string to Java object.
Deserialize the given JSON string to Java object .
public Object deserialize(String json, String containerType, Class cls) throws ApiException {
        if (null != containerType) {
            containerType = containerType.toLowerCase();
        }
        try {
            if ("list".equals(containerType) || "array".equals(containerType)) {
                JavaType typeInfo = Json.mapper().getTypeFactory().constructCollectionType(List.class, cls);
                List response = (List<?>) Json.mapper().readValue(json, typeInfo);
                return response;
            } else if (String.class.equals(cls)) {
                if (json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) {
                    return json.substring(1, json.length() - 2);
                } else {
                    return json;
                }
            } else {
                return Json.mapper().readValue(json, cls);
            }
        } catch (IOException e) {
            throw new ApiException(500, e.getMessage(), null, json);
        }
    }
public Object deserialize ( String json , String containerType , Class cls ) throws ApiException { if ( null != containerType ) { containerType = containerType . toLowerCase ( ) ; } try { if ( "list" . equals ( containerType ) || "array" . equals ( containerType ) ) { JavaType typeInfo = Json . mapper ( ) . getTypeFactory ( ) . constructCollectionType ( List . class , cls ) ; List response = ( List < ? > ) Json . mapper ( ) . readValue ( json , typeInfo ) ; return response ; } else if ( String . class . equals ( cls ) ) { if ( json != null && json . startsWith ( "\"" ) && json . endsWith ( "\"" ) && json . length ( ) > 1 ) { return json . substring ( 1 , json . length ( ) - 2 ) ; } else { return json ; } } else { return Json . mapper ( ) . readValue ( json , cls ) ; } } catch ( IOException e ) { throw new ApiException ( 500 , e . getMessage ( ) , null , json ) ; } }
Deserialize the given JSON string to Java object.
Deserialize the given JSON string to Java object .