我有一个要转换为 JSON 的类,但构造函数不允许我这样做。该类称为 CourseKeyInfo:
public class CourseKeyInfo
{
private String courseKey;
private String institutionID;
public CourseKeyInfo(String courseKey, String institutionId)
{
this.courseKey = courseKey;
this.institutionID = institutionId;
}
public String getCourseKey()
{
return courseKey;
}
public void setCourseKey(String courseKey)
{
this.courseKey = courseKey;
}
public String getInstitutionID()
{
return institutionID;
}
public void setInstitutionID(String institutionID)
{
this.institutionID = institutionID;
}
}
我曾经JSONObject body = new JSONObject(responseEntity);
将其转换为 json,但它给了我“构造函数 JSONObject(CourseKeyInfo) 未定义”错误。知道如何将我的课程变成 json 吗?