
com.github.bingoohuang.springrestclient.utils.Beans Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-rest-client Show documentation
Show all versions of spring-rest-client Show documentation
convenient spring rest client for rest services
package com.github.bingoohuang.springrestclient.utils;
import com.alibaba.fastjson.JSON;
import com.github.bingoohuang.springrestclient.xml.Xmls;
import com.github.bingoohuang.utils.codec.Json;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Type;
@UtilityClass
public class Beans {
public Object unmarshal(String text, Class> clazz) {
if (StringUtils.isEmpty(text)) return null;
return text.startsWith("<")
? Xmls.unmarshal(text, clazz)
: (text.startsWith("{")
? Json.unJson(text, clazz)
: Json.unJsonArray(text, clazz));
}
public Object unmarshal(String text, Type returnType) {
return JSON.parseObject(text, returnType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy