0

I am reading a Stackoverflow post (here), I am writing the code contained in the answer but I can't instantiate a JSONObject. The post don't specify where JSONObject comes from so imported it as follows:

  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.
Diego Alves
  • 2,462
  • 3
  • 32
  • 65

1 Answers1

2

You probably want org.json.JSONObject. That one has a constructor that takes a String.

RobCo
  • 6,240
  • 2
  • 19
  • 26
  • I am new to java I see that is very common to find classes with the same name that come from different packages. – Diego Alves Jan 15 '18 at 14:47