Java

[Java] String -> Json

IT공부블로그 2020. 4. 1. 18:27
728x90
반응형


net.sf.json.JSONObject일 경우



1
2
3
public JSONObject stringToJSONObject(String json) throws ParseException {
    return JSONObject.fromObject(JSONSerializer.toJSON(json));
}
cs


org.json.simple.JSONObject일 경우


1
2
3
public JSONObject stringToJSONObject(String json) throws ParseException {
    return (JSONObject) new JSONParser().parse(json);
}
cs


728x90
반응형