判断字符串是不是JSONObject 或 JSONArray
方法1
Object json = new JSONTokener(jsonValue).nextValue();
if (json instanceof JSONObject) {
} else if (json instanceof JSONArray) {
}
方法2
public static boolean isJson(String value) {
try {
new org.json.JSONObject(value);
} catch (org.json.JSONException e) {
return false;
}
return true;
}
相关推荐
somebodyoneday 2020-06-15
83163452 2020-01-28
adonislu 2020-01-10
baijinswpu 2020-01-01
adonislu 2019-12-31
xufankang 2019-12-19
somebodyoneday 2019-12-07
somebodyoneday 2019-10-30
ZCMUCZX 2016-04-14
WebVincent 2020-07-21
fengchao000 2020-07-04
baijinswpu 2020-06-28
88483063 2020-06-28
fengchao000 2020-06-16
wujiajax 2020-06-14
somebodyoneday 2020-05-16
xx0cw 2020-05-16
newthon 2020-05-14