Reputation: 159
I am returning HashMap<Long,String>
from server on one of the Ajax calls. How can I iterate over the it to extract key,value pair?
Thank you
Upvotes: 0
Views: 2058
Reputation: 328724
Return it as JSON object:
{1:"String",5:"Foo"}
On the client, you can then access the elements then using data[1]
and data[5]
. While it looks like an array access, JavaScript will do the right thing (Kudos to Felix Kling for pointing that out).
Upvotes: 1