0

I realise that there are already many questions addressing this issue, however hear me out please.

I have a .json file that I am loading locally on my android device and my JSON Object have a particular order of keys and values and when I use the jsonObject.keys() method, I get an iterator where as expected, the order of keys is not maintained in the iterator.

This answer addresses this issue

However when I check the source code of the org.json.JSONObject file, it uses LinkedHashmap and not the HashMap and in the many many answers I read online, using linkedHashMap solves the problem.

However, it does not work for me, the order of the keys is not maintained.

The current JSONObject constructer:

 public JSONObject() {
    nameValuePairs = new LinkedHashMap<String, Object>();
}
Community
  • 1
  • 1
Chintan Shah
  • 935
  • 2
  • 9
  • 28

0 Answers0