I want to put in a JSONArray the values of a CSV, which i can do now with the following code, but the JSONArray does not have the same order my CSV String has, can someone please help? I'm using org.json.
InputStream is = file.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String inputStr, csv = "";
while ((inputStr = br.readLine()) != null){
csv += inputStr +"\n";
}
JSONArray array = CDL.toJSONArray(csv);
I did not find an easier way to convert the CSV to a JSONArray, the csv String is in the right order and the array is created OK except the array is un-ordered, thanks in advance for any suggestion that might help.
I saw this post but it's kind of backwards of what i need (JSONArray to CSV) Keep the order of the JSON keys during JSON conversion to CSV