为什么我不能在Java中实例化JSONObject(字符串无法转换为map)

时间:2018-01-15 13:32:33

标签: java

我正在阅读Stackoverflow帖子(here),我正在编写答案中包含的代码,但我无法实例化JSONObject。帖子没有指定JSONObject的来源,因此将其导入如下:

  import org.json.simple.JSONObject;  

  String jsonData = response.body().string();
  JSONObject json = new JSONObject(jsonData); //jsonData marked as the soruce of the error and the message "incompatible types cannot convert string to map" shows.

1 个答案:

答案 0 :(得分:2)

你可能想要org.json.JSONObject。那个有一个带String的构造函数。