当我运行以下代码时......
JSONObject jsonObject = null;
JSONParser parser=new JSONParser(); // this needs the "json-simple" library
try
{
Object obj = parser.parse(responseBody);
jsonObject=(JSONObject)obj;
}
catch(Exception ex)
{
Log.v("TEST","Exception1: " + ex.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
...在运行时我在日志输出中看到以下内容:
Exception1: org.json.simple.JSONObject cannot be cast to org.json.JSONObject
Run Code Online (Sandbox Code Playgroud)
我不明白为什么.
Hen*_*nry 17
您导入了错误的类.更改
import org.json.JSONObject;
Run Code Online (Sandbox Code Playgroud)
至
import org.json.simple.JSONObject;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23045 次 |
| 最近记录: |