Example usage for org.json CDL toJSONArray

List of usage examples for org.json CDL toJSONArray

Introduction

In this page you can find the example usage for org.json CDL toJSONArray.

Prototype

public static JSONArray toJSONArray(JSONTokener x) throws JSONException 

Source Link

Document

Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.

Usage

From source file:net.iubris.ipc_d3.cap.CamelizeSomeFieldsAndExtractInformazioniStoricheDates.java

private JSONArray adjustTimeAndTipiSpecifici(String dataAsCSV) throws ParseException {
    JSONArray jsonArray = CDL.toJSONArray(dataAsCSV);
    int length = jsonArray.length();
    JSONArray jsonArrayNew = new JSONArray();
    for (int i = 0; i < length; i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);

        JSONObject jsonObjectNew = new JSONObject();

        jsonObjectNew.put("nome", jsonObject.getString("nome"));
        jsonObjectNew.put("indirizzo", jsonObject.getString("indirizzo"));
        jsonObjectNew.put("numeroCivico", jsonObject.getString("numero-civico"));
        jsonObjectNew.put("cap", jsonObject.getString("cap"));
        jsonObjectNew.put("quartiere", jsonObject.getString("quartiere"));
        jsonObjectNew.put("citta", jsonObject.getString("citta"));
        jsonObjectNew.put("geolocazione", jsonObject.getString("geolocazione"));
        jsonObjectNew.put("telefono", jsonObject.getString("telefono"));
        jsonObjectNew.put("mobile", jsonObject.getString("mobile"));
        jsonObjectNew.put("email", jsonObject.getString("email"));
        jsonObjectNew.put("web", jsonObject.getString("web"));
        jsonObjectNew.put("tipi", jsonObject.getString("tipi"));
        jsonObjectNew.put("tipiSpecifici", jsonObject.getString("tipi-specifici"));

        //         jsonObjectNew.put("tipiSpecificiReduced", getTipiReduced(jsonObject));
        //         jsonObjectNew.put("times", getTimes(jsonObject));

        LinkedList<String> date = findNumbers(jsonObject.getString("luogo-da-visitare.informazioni_storiche"));
        String dateString = date.toString().replace("[", "").replace("]", "");
        jsonObjectNew.put("luoghiDaVisitare.informazioniStoriche.date", dateString);

        jsonArrayNew.put(jsonObjectNew);
    }/*ww w .j  av  a 2 s  . c om*/
    return jsonArrayNew;
}