[json-lib-user] Converting JSONSerializer.toJSON
Brought to you by:
aalmiray
From: Haritha J. <har...@ya...> - 2008-06-25 19:07:27
|
Hi All/Andres I have a LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); which has objects sorted in order of insertion. What i am trying to do is convert this to a JSON string by using the following code JSONObject json = (JSONObject) JSONSerializer.toJSON( allPhotos ); json.toString(); When i do this the JSON that is created looses the order of the elements in allPhotos. Example I put data in this order allPhotos.put('abc','david'); allPhotos.put('cdg','jason'); allPhotos.put('efg','brian'); But my final json string looks like this {"cdg":"jason","efg":"brian","abc":"david"} Retaining this order is important to our application. Can anyone tell me how i can achieve that? Thanks Haritha |