Just something to keep in mind:
Code: Select all
JSONObject test = new JSONObject();
int userId = 10;
test.put(userId, "hello");
trace("Result: " + test.containsKey(userId));
Result traces out
false. Same problem will occur for test.get(userId). However, if you send the 'test' JSONObject back to client, the data is there which took me a while to narrow down the problem.
Code: Select all
JSONObject test = new JSONObject();
int userId = 10;
test.put(userId, "hello");
trace("Result: " + test.containsKey(String.valueOf(userId)));
Result now traces out
true. Casting the userId as String is the workaround.
Smartfox's forum is my daily newspaper.