1. 程式人生 > 其它 >java判斷字串是否可以轉化為json

java判斷字串是否可以轉化為json

技術標籤:後端java

/**
 * 判斷字串是否可以轉化為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; } }