java判断字符串是否可以转化为json

/**
 * 判断字符串是否可以转化为json对象
 * @param content
 * @return
 */
import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;
public static boolean isJsonObject(String content) {
	// 字符串判空
	if(StringUtils.isBlank(content))
		return false;
	try {
		JSONObject jsonStr = (JSONObject) JSONValue.parse(content);
		return true;
	} catch (Exception e) {
		return false;
	}
}

你可能感兴趣的:(后端)