I created an application that uses JSON for the database, and it seems to write fine, and the file reader reads the database fine, but I cant seem to get the database values from the database value.
here is my parsing code:
String userEnteredString = UserEntered.getText();
String userHomeLocal = Tutschedule.userHome;
Reader dataFile = null;
try {
dataFile = new FileReader(userHomeLocal+"/Users/"+userEnteredString+".data");
} catch (FileNotFoundException ex) {
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
String dbData = dataFile.toString();
try {
JSONObject dbObject = new JSONObject(dbData);
} catch (JSONException ex) {
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(dbData);
JSONObject dataInfo = new JSONObject(dbData);
String password = dataInfo.getString("password");
System.out.println(password);
BufferedReader buffered = new BufferedReader(dataFile);
String test = null;
try {
test = buffered.readLine();
} catch (IOException ex) {
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
The problem is when I print password it doesnt print anything, leading me to think that the password field is not processed.
here is an example of the database:
{"username":"user","password":"test"}
Thanks!
System.out.println(dbData);is executed?