It seems like you are missing a dependency json-simple.
1) Here is the link JSON.simple » 1.1.1 where you can download missing dependency.
2) Add downloaded dependency

3) If you have the maven or gradle project then copy dependencies line.

4) Then clean build the project and see the magic.
Answer from Dushyant Tankariya on Stack OverflowIt seems like you are missing a dependency json-simple.
1) Here is the link JSON.simple » 1.1.1 where you can download missing dependency.
2) Add downloaded dependency

3) If you have the maven or gradle project then copy dependencies line.

4) Then clean build the project and see the magic.
Here As you're facing an error like; JSONParser it shows "The constructor JSONParser() is deprecated" because You've not used it correctly to get your JSON file data I've posted below sample code where you can get the idea.
import java.io.FileReader;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
public class JsonFileReader {
public static void main(String[] args) {
try {
JSONParser parser = new JSONParser();
JSONObject obj = (JSONObject)parser.parse(new FileReader("L:/data.json"));
String name = (String) obj.get("USERNAME");
String password = (String) obj.get("PASSWORD");
System.out.println("Name: " + name);
System.out.println("Password: " + password);
} catch (Exception ex) {
System.out.println("Exception: "+ ex.getMessage());
}
}
}
note: Here I've used the same "json-simple-1.1.1.jar" file.
File: data.json
{
"USERNAME": "abc",
"PASSWORD": "xyz"
}
Videos
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
The other answer is a bit out-dated. ( At the end of 2018 compile will be either api or implementation also there is a new version 1.1.1 )
Add this to the build.gradle dependencies:
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
and then import
import org.json.simple.parser.JSONParser;
Hope it helps as it does to me :)
use these dependencies
jackson-databind
jackson-annotations
jackson-core
public class JsonTest {
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper=new ObjectMapper();
Map<String,String> dt=new Hashtable();
dt.put("1", "welcome");
dt.put("2", "bye");
String jsonString = mapper.writeValueAsString(dt)
System.out.println(jsonString);
}
}
Looks like mixed up references.
You might be using a library that uses an old version of Jackson itself (i.e. the org.codehaus package)...
I usually just reference Jackson through Maven.
Something like:
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>