All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mashape.unirest.request.ValueUtils Maven / Gradle / Ivy

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);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy