class JsonToCsvConverter {

    public String convert(String jsonData) throws JSONException {
        Set<String> columns;
        JSONArray array = new JSONArray(jsonData);

        JSONObject fullPropertyMap = extractFullPropertyMap(array);

        columns = extractColumns(fullPropertyMap);

        String csvResult = buildColumnsLine(columns);

        csvResult += buildDataLines(array, fullPropertyMap);

        return csvResult;
    }

}