a JSONObject
doesn’t guarantee any order for its keys, it may sometimes be in the order of insertion, and sometimes not.
If you need to keep the order of insertion, use a JSONArray instead.
solved Why Json Object order mixed up in android KITKAT and below versions?