JSONObject: int values as key doesn't work properly
Posted: 08 Apr 2011, 04:24
Just something to keep in mind:
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.
Result now traces out true. Casting the userId as String is the workaround.
Code: Select all
JSONObject test = new JSONObject();
int userId = 10;
test.put(userId, "hello");
trace("Result: " + test.containsKey(userId));Code: Select all
JSONObject test = new JSONObject();
int userId = 10;
test.put(userId, "hello");
trace("Result: " + test.containsKey(String.valueOf(userId)));