Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将org.json.simple.JSONObject转换为java.lang.String_Java_Json_Json Simple - Fatal编程技术网

无法将org.json.simple.JSONObject转换为java.lang.String

无法将org.json.simple.JSONObject转换为java.lang.String,java,json,json-simple,Java,Json,Json Simple,我想将cliendId和clientSecret检索到两个不同的字符串中 我正在努力 String responseEntity = secretRequestMap.get("responseEntity").toString(); 要将responseEntity转换为字符串,然后使用JSON解析器再次解析它,但它会在线程“main”中引发异常: 当我检查时,它不会显示任何错误,但当我运行时,它会抛出异常。请帮忙 String response = {"statusCode":"200"

我想将cliendId和clientSecret检索到两个不同的字符串中

我正在努力

String responseEntity = secretRequestMap.get("responseEntity").toString(); 
要将responseEntity转换为字符串,然后使用JSON解析器再次解析它,但它会在线程“main”中引发异常:

当我检查时,它不会显示任何错误,但当我运行时,它会抛出异常。请帮忙

String response = {"statusCode":"200","responseEntity":{"clientId":"abc","clientSecret":"xyz"},"errorList":[]};
Map<String, String> responseMap  = (Map<String, String>) new JSONParser().parse(response);
String response={“statusCode”:“200”,“responseEntity”:{“clientId”:“abc”,“clientSecret”:“xyz”},“errorList”:[]};
Map responseMap=(Map)new JSONParser().parse(response);
使用
(字符串)
强制转换它,因为它将作为对象返回

String responseEntity =(String) secretRequestMap.get("responseEntity").toString(); 

因此,您是否看到任何地方说
toString
JSONObject
的方法?@HotLicks
toString()
是所有
对象的方法,您无法获得运行时异常<代码>字符串响应={“statusCode”:“200”
未编译…
字符串响应属性=(String)secretRequestMap.get(“响应属性”).toString();
String responseEntity =(String) secretRequestMap.get("responseEntity").toString();