java - Without looping get the index position in a JSONArray -


i have following jsonobject

{"results":2,"object":[{"id":10,"rank":12},{"id":21,"rank":22}.........{"id":n,"rank":n}]} 

now if have id: 21, how position of object?

is there direct way position of id?

like 21 in 2nd position in array.so index position 1. there direct way without looping jsonarray improve performance?

one thing can re-structure json like

{"results":2,"object":{10:{"pos":1,"rank":12},21:{"pos":2,"rank":22}.........n:{"pos":n,"rank":n}}} 

then can directly fetch using object[ur_id].pos


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -