org.json.simple.JSONObject无法转换为org.json.JSONObject [英] org.json.simple.JSONObject cannot be cast to org.json.JSONObject
本文介绍了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;
这篇关于org.json.simple.JSONObject无法转换为org.json.JSONObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文