불필요한 로직 제거 및 json 처리 메소드 이동

This commit is contained in:
curry772
2026-06-12 09:14:28 +09:00
parent 05a456b461
commit a616cd6334
2 changed files with 31 additions and 8 deletions
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class JSONUtils {
@@ -19,6 +20,30 @@ public class JSONUtils {
private JSONUtils() {
throw new IllegalStateException("Utility class");
}
public static Object parseJsonGeneric(Object jsonData) {
if (jsonData == null) {
return new JSONObject();
}
if (jsonData instanceof JSONObject) {
return (JSONObject) jsonData;
} else if (jsonData instanceof String) {
if (StringUtils.isBlank((String) jsonData)) {
return new JSONObject();
}
try {
JSONParser parser = new JSONParser();
Object parsedObj = parser.parse((String) jsonData);
return parsedObj;
} catch (ParseException e) {
e.printStackTrace();
return null;
}
} else
throw new IllegalArgumentException("not support json type. " + jsonData.getClass());
}
public static JSONObject parseJson(Object message) {
if (message == null) {