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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -