com.mashape.unirest.request.ValueUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unirest-java Show documentation
Show all versions of unirest-java Show documentation
Simplified, lightweight HTTP client library
The newest version!
package com.mashape.unirest.request;
import com.alibaba.fastjson.JSON;
import com.google.common.primitives.Primitives;
public class ValueUtils {
public static String processValue(Object value) {
return (value == null) ? "" : tryJson(value);
}
private static String tryJson(Object value) {
if (value instanceof CharSequence ) return value.toString();
if (value.getClass().isPrimitive()) return value.toString();
if (Primitives.isWrapperType(value.getClass())) return value.toString();
if (value instanceof Enum) return value.toString();
return JSON.toJSONString(value);
}
}