Loading ...
Sorry, an error occurred while loading the content.

Re: [json] Ordered JSONObject?

Expand Messages
  • Bakul L Patel
    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
    Message 1 of 3 , Jun 27 12:05 AM
    • 0 Attachment
      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:
      >
      >{"test":{"97523":{"attrs":{},"name":{"rec":41523}},
      > "654712":{"attrs":{},"name":{"rec":106512}},
      > "3895608":{"attrs":{},"name":{"rec":238908}}},
      > "code":"OK"}
      >
      >It is very useful in javascript to be able to directly access specific
      >rows in this manner:
      >x.test[97523].name.rec
      >
      >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?
      >
      >Thanks
      >
      >
      >


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.