I have some JSON returned from my web-service like below:
{
"error": false,
"users": [
{
"id": "1",
"username": "user001",
"level": 10,
"last_updated": "22072014"
}
{
"id": "2",
"username": "user002",
"level": 11,
"last_updated": "21072014"
}
]
}
I'm building up a long list of items for each user and I want just display them to the screen in the order that they are listed (so id, then username, level, last_updated, etc).
From this post: JSON order mixed up "An object is an unordered set of name/value pairs" - I understand that JSONObjects are unordered maps. There is a suggestion of using LinkedHashMap to retrieve the ordered information.
I'm using Volley with a request similar to below:
JsonObjectRequest jsonReq = new JsonObjectRequest(Method.POST,
URL, params, new Response.Listener<JSONObject>(){ .. }
Is it possible to use the LinkedHashMap or is there any way of maintaining the order of each users attributes as they are received?