So I have imported import org.json.*
and It doesnt seem to recognize JSONParser.
String filePath = "C://CN//jokes.json";
try {
FileReader reader = new FileReader(filePath);
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);
System.out.println(jsonObject);
}catch (Exception e) {
System.out.println(e);
}
}
jokes.json has the same information as http://api.icndb.com/jokes I want to be able to get the data from that site, but to test I have created a file. This is my first time using Json so I'm a bit clueless. I have updated the jdk and jre, but I still have the same issue. Here is a screenshot showing how it looks: Screenshot I have also read a similar post link, but it is different from my problem.
If you look at the screenshot it seems import org.json.*
doesnt have class JSONParser. I have also tried adding import org.json.simple.parser.JSONParser;
but it doesnt recognize it. because "simple" doesnt exist
For Android Studio, just add this to the build.gradle dependencies:
compile 'com.googlecode.json-simple:json-simple:1.1'
For other IDEs and other options, see here: http://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With