I am using json simple
this is my code:
public static String getDetails() {
String name = System.getProperty("user.name");
JSONParser parser = new JSONParser();
File dir = new File("C:\\Users\\" + name + "\\AppData\\Roaming\\.minecraft\\launcher_profiles.json");
if (dir.exists()) {
Object obj = null;
try {
obj = parser.parse(new FileReader("C:\\Users\\" + name + "\\AppData\\Roaming\\.minecraft\\launcher_profiles.json"));
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObject = (JSONObject) obj;
String da = (String) jsonObject.get("username");
try {
return obj.toString() + "\n" + da;
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("dir no exist");
}
return null;
}
when i print this out it returns all the text in the json file and it returns null from String 'da' I dont know why because its not null it exist in the file??
JSON file: https://hastebin.com/sirefacado.json