You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
717 B
32 lines
717 B
package com.bfd.qanda.utils;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.bfd.qanda.entity.Constants;
|
|
|
|
/**
|
|
* json工具
|
|
* @author jian.mao
|
|
* @date 2023年7月10日
|
|
* @description
|
|
*/
|
|
public class JsonUtil {
|
|
|
|
/**
|
|
* 校验字符串是list/map/str
|
|
* @param jsonString
|
|
* @return
|
|
*/
|
|
public static String checkJsonType(String jsonString) {
|
|
try {
|
|
JSONObject.parseObject(jsonString);
|
|
return Constants.MAP_TYPE;
|
|
} catch (Exception e) {
|
|
try {
|
|
JSONObject.parseArray(jsonString);
|
|
return Constants.LIST_TYPE;
|
|
} catch (Exception ex) {
|
|
return Constants.STRING_TYPE;
|
|
}
|
|
}
|
|
}
|
|
}
|