1 Replies - 2572 Views - Last Post: 01 April 2012 - 03:28 AM

#1 akranjec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 12

Compare JSONobject with String?

Posted 31 March 2012 - 04:41 PM

String checkLoginJSON = "[{\"Authenticated\":\"ok\",\"SessionId\":\"1234\"}]";

JSONArray entries = new JSONArray(checkLoginJSON);
    				
if(entries.getJSONObject(0).getString("Authenticated") == "ok"){
//ServerComm.sessionId = entries.getJSONObject(0).getString("SessionId").toString();
    					
Toast.makeText(LoginActivity.this, "Login Successful",Toast.LENGTH_LONG).show();

Intent i = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(i);
finish();
}



Can anyone help me? I'm geting exception when trying tu compare JSONobject with string.

Is This A Good Question/Topic? 0
  • +

Replies To: Compare JSONobject with String?

#2 akranjec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 12

Re: Compare JSONobject with String?

Posted 01 April 2012 - 03:28 AM

Well problem is that I haven't used JAVA for a while.

if(entries.getJSONObject(0).getString("Authenticated").equals("true"))


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1