Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


when jsonobjects keys are iterated they arent in the same order as in the resp using -'java,json'


when jsonobjects keys are iterated they arent in the same order as in the resp  using -'java,json'

I have a very large response from server of JSON string. I converted it to JSON object and then get the keys and iterate it.

The problem is that when I iterate it isnt in the same order as in response from server.

Next then I apply another method by adding all the keys in List<String> and the sort it and then get the iterator of that but still it isn't as I required (as in response).

Code example is here:

JSONObject jsonObject = new JSONObject(responseString);
    Iterator<String> myIter = jsonObject.keys();


    List<String> sortKey = new ArrayList<String>();

    while(myIter.hasNext()){
        sortKey.add(myIter.next());
    }
    Collections.sort(sortKey);

    

asked Sep 7, 2015 by rajesh
0 votes
3 views



Related Hot Questions



Government Jobs Opening


...