Well, if you dig API little, you would come to know that it uses HashMap that does not keep that element in any order.
May be you can use LinkedHashMap for your purpose. But for that you need to change the API that you have got from json.org.
On Tue, 27 Jun 2006 sco1326 wrote :
>I need to create a JSON object using the Java json.org API in the
>format of the following example:
>rows in this manner:
>The problem is I need the named array values to be in a sorted order.
> The JSONObject is very clear about it being an unordered collection.
> Is there any way to maintain this structure and return an ordered
>object using the Java json.org objects?
>Any suggestions on how to achieve these goals or something similar?
[Non-text portions of this message have been removed]