Hello
I'm trying to learn the JSON and it's intricacies.
I'm using the JSONget example as a starter.. I want to do conditionnals, but it never returns true.
Even using the debugger, it all seem ok and the same, t and a will give type java.lang.String = "Wilbert"
what am I missing here? I'm confused..
Thanks for the help
---- CODE --
import http.requests.*;
public void setup()
{
size(100,100);
smooth();
GetRequest get = new GetRequest("http://connect.doodle3d.com/api/list.example");
get.send(); // program will wait untill the request is completed
println("response: " + get.getContent());
JSONObject response = parseJSONObject(get.getContent());
println("status: " + response.getString("status"));
JSONArray boxes = response.getJSONArray("data");
println("boxes: ");
for(int i=0;i<boxes.size();i++) {
JSONObject box = boxes.getJSONObject(i);
String t = box.getString("wifiboxid");
String a = "Wilbert";
println("t : "+ t); //confirms the name to compare
println(t.length()); // confirms length, so no extra characters
println(a.length()); // confirms length, so no extra characters
if ( t == a) // compare but never true
{
println(" wifiboxid: " + box.getString("wifiboxid"));
println(" remoteip: " + box.getString("remoteip"));
}
}
}
---- JSON -----
http://connect.doodle3d.com/api/list.example
{
"status":"success",
"data":[
{
"id":"62.216.8.197\/10.0.0.18",
"remoteip":"62.216.8.197",
"localip":"10.0.0.18",
"wifiboxid":"Albert",
"hidden":"0",
"date":"2013-10-03 17:24:33",
},
{
"id":"62.216.8.197\/10.0.0.29",
"remoteip":"62.216.8.197",
"localip":"10.0.0.29",
"wifiboxid":"Wilbert",
"hidden":"0",
"date":"2013-10-03 17:52:19"
}
],
}