com.aliyuncs.v5.unmarshaller.JsonUnmashaller Maven / Gradle / Ivy
package com.aliyuncs.v5.unmarshaller;
import com.aliyuncs.v5.AcsResponse;
import com.aliyuncs.v5.exceptions.ClientException;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
public class JsonUnmashaller implements Unmarshaller {
@Override
public T unmarshal(Class clazz, String content) throws ClientException {
try {
return (new Gson()).fromJson(content, clazz);
} catch (JsonSyntaxException e) {
throw newUnmarshalException(clazz, content, e);
}
}
private ClientException newUnmarshalException(Class> clazz, String content, Exception e) {
return new ClientException("SDK.UnmarshalFailed",
"unmarshal response from json content failed, clazz = " + clazz.getSimpleName() + ", origin response = " + content, e);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy