org.json.simple.JSONObject无法转换为org.json.JSONObject
问题描述:
当我运行以下代码时...
When I run the following code...
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());
}
...在运行时,我在日志输出中看到以下内容:
...at runtime I see the following in my log output:
Exception1: org.json.simple.JSONObject cannot be cast to org.json.JSONObject
我不明白为什么.
答
您导入了错误的类.更改
You have imported the wrong class. Change
import org.json.JSONObject;
到
import org.json.simple.JSONObject;