我的JSONObject:
JSONObject callback = {"message": "message here", "response": "response here"}
我想从 json的respone 字符串中获取响应。 我尝试了以下内容:
JSONObject response = callback.getJSONObject("response");
String message = next.getString("response");
我得到的错误就像字符串和JSONObjet转换问题。
答案 0 :(得分:1)
JSONObject回调= {"消息":"此处有消息","响应":"响应此处"}
您需要访问响应值,如下面的代码
String response = callback.getString("response");
答案 1 :(得分:1)
试试如下:
JSONObject callback = {"message": "message here", "response": "response here"}
String response = callback.getString("response");
String message = callback.getString("message");