Class JSONWriterToCSV


  • public class JSONWriterToCSV
    extends DefaultJsonDataService.QueryResultWriter
    Helper class to write JSON objects to generate a CSV file using the standard preferences. This class will be commonly used by first creating a new instance and that will write the header in the writer, then invoking the write method for each of the json objects that need to be written and then by invoking the writeCSVFooterNote method to write the fotter, if any.
    • Constructor Detail

      • JSONWriterToCSV

        public JSONWriterToCSV​(Writer printWriter,
                               VariablesSecureApp vars,
                               Map<String,​String> parameters,
                               Entity entity)
        Parameters:
        printWriter - Writer that will be used to write the results of the export process.
        vars - VariablseSecureApp with the session data.
        parameters - It contains the parameters required to build properly the CSV file.
        entity - Entity to load the properties.
    • Method Detail

      • getFieldProperties

        public List<String> getFieldProperties()
        Get selected properties those that will finally be exported.
      • write

        public void write​(org.codehaus.jettison.json.JSONObject json)
        Writes the JSON object as a record in CSV format based on the class parameters settings.
        Specified by:
        write in class DefaultJsonDataService.QueryResultWriter
        Parameters:
        json - JSON object to convert to CSV record.