import org.json.simple.JSONObject;
String resStr = {"dataBody":{"result_msg":"성공","result_cd":"0000"}};
// {"dataBody":{"result_msg":"성공","result_cd":"0000"}}
JSONObject resObj = JsonUtil.toObject(resStr, JSONObject.class); // ObjectMapper
JSONObject dataBodyObj = (JSONObject) resObj.get("dataBody");
// java.util.LinkedHashMap cannot be cast to org.json.simple.JSONObject
JsonUtil.toObject > ObjectMapper (Jackson) 가 JSON 을 역직렬화할 때
1. JSONObject 내에 어떤 자료형 요소가 있어야 하는지 알 수 없다.
2. 기본 자료형 은 LinkedHashMap.
=> ClassCastException 발생!
JSONObject dataBodyObj = JsonUtil.convertValue(resObj.get("dataBody"), JSONObject.class); // ObjectMapper
// {"result_msg":"성공","result_cd":"0000"}