Keep the order of the JSON keys during JSON conversion to CSV

I am using the JSON library provided here to convert a json string I have to CSV. But the problem I have is, the order of the keys is lost after conversion.

This is the conversion code:

    JSONObject jo = new JSONObject(someString);
    JSONArray ja = jo.getJSONArray("items");
    String s = CDL.toString(ja);

This is the content of “someString”:


This is the result:


While what I expect is to keep the order of the keys:


Is there any way I can have this result using this library? If not, is there any other library that will provide the capability to keep the order of keys in the result?



I used the JSON.simple library from here to read the JSON string to keep the order of keys and use JavaCSV library from here to convert to CSV format.