java判斷字串是否可以轉化為json
阿新 • • 發佈:2021-01-21
/**
* 判斷字串是否可以轉化為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;
}
}