public String IgetFreecourseNameForAndroid() {
JSONObject json = new JSONObject();
try {
json.put("season", "秋季课");
return json.toString();
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
取值
另一个类中
String season = userReg.IgetFreecourseNameForAndroid();
JSONObject obj = new JSONObject(season);
System.out.println( obj.get("season") );
本文介绍了一个Java方法,用于设置和获取JSON对象中的季节课程名称,通过实例演示了如何在不同类间调用该方法并解析返回的JSON字符串。
500

被折叠的 条评论
为什么被折叠?



