com.aliyuncs.unmarshaller.JsonUnmashaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliyun-java-sdk-core Show documentation
Show all versions of aliyun-java-sdk-core Show documentation
Aliyun Open API SDK for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
The newest version!
package com.aliyuncs.unmarshaller;
import com.aliyuncs.AcsResponse;
import com.aliyuncs.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