伙计们,我正试图从一个JSONOject中填充一个bean,但它给我带来了一个例外64: JSONOject java.lang.String与net.sf.json.JSONObject不兼容“
61: for( Object myObject : studentsGradeArray )
62: {
63:
64: JSONObject studentGradeJSON = (JSONObject) myObject;可能的原因是什么?
发布于 2011-06-09 16:16:00
看起来,您得到的是一个String对象,而不是所需的JSONObject。假设studentsGradeArray中的所有对象都是JSON对象.
for( Object myObject : studentsGradeArray ) {
JSONObject studentGradeJSON = JSONObject.fromObject(myObject);
// the rest of your code
}更多信息可以在JSONObject文档中找到。
发布于 2011-06-09 16:15:44
studentsGradeArray的元素是字符串类型的,而不是JSONObject类型的。
你可能想说
JSONObject studentGradeJSON = new JSONObject(myObject) https://stackoverflow.com/questions/6295944
复制相似问题