How to Use the API

There are two ways of using this application. The first is to use the interface provided to do conversions of CSV to JSON, with or without nesting.

The second way is to fork the repo and set it up on your own server. This will then allow it to be used as an API that dynamically converts CSV to JSON and directly feeds it into applications that need JSON formatted a specific way. This is done using a URL like this one: jsonifyit.com/output?parameter1=something&parameter2=somethingelse...

The full range of parameters that can be passed in the URL are listed below.


Input Options

  • file_or_input - [String] Two possible values – file or input. Input if the data is being passed with the request, file if the data is sitting on the server already.
  • file_name - [String, optional] The name of the file (minus file type) if file is selected instead of input. Required if file_or_input is set to "file".
  • csv_sep - [String, optional] The character used to delimit the data. Defaults to ",".
  • header_sel - [Boolean, optional] Whether the first row should be considered a header row. Defaults to True.
  • index_col - [String, optional] The name of the index column, if there is one. Having an index column will impact that structure of the JSON differently depending on the base_structure specified.
  • filter_col - [String, optional] The name of a column to filter the dataset on.
  • filter_val - [String, optional] The value to look for in filter_col.
  • limit - [Integer, optional] Only the first X rows of the dataset will be processed to create the JSON.

Output Options

  • base_structure - [String, optional] The structure of the JSON (inside the nesting). Based on the pandas DataFrame.to_dict method options. Defaults to "records".
  • group_by - [Integer, optional] Nests the first X columns of the dataset.
  • col_names - [String, optional] A comma seperated list of columns to nest by. Will override group_by if provided.
  • name_key - [String, optional] The name of the key that stores the nested value at each level. Default is "name".
  • child_key - [String, optional] The name of the key that stores the nested array of data at each level. Default is "children".
  • sum_field - [String, optional] The column to sum at each level of nesting.
  • sum_field_name - [String, optional] The name of the key for the summed value at each level of nesting.
  • avg_field - [String, optional] The column to average at each level of nesting.
  • avg_field_name - [String, optional] The name of the key for the averaged value at each level of nesting.
  • wrapper - [Boolean, optional] Whether to wrap the JSON in a outer layer. If True, child_key will determine the key used. Defaults to False.
  • root_node - [String, optional] Value for the name key in the wrapper layer of the JSON (if wrapper is set to True). Defaults to "data".

Issues

Something not working or not working as described? Please raise an issue on the repo.