I would like to compare a row from mysql database using JSON with my row. I got the data from the database, and the log shows that I have all the data.
try{
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
json_data = jArray.getJSONObject(i);
Log.i("mylog","TABLE_NAME: "+json_data.getString("table_name"));
if ( json_data.getString("table_name") == "cars" ) {
....
}
}
} catch(JSONException e){
Log.e("mylog", "Error parsing data "+e.toString());
return false;
}
and in this example in the log I got the table name: cars And below the EU condition does not work, and I have no idea WHY. This is strange. I have tried many ways.
Do you know why I cannot compare table_name from JSON with a simple string?
Tom b source
share