Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

vutil provides a REST API to fetch CSV files which is stored on your local machine. This API accepts the filePath of the CSV file as input and converts it into JSON format and respond this JSON as API response.

Now, with the help of this API, we can perform data driven testing in vREST, where external data is stored in your local system in CSV format.

This  API fetches the CSV file from machine on which this utility is installed. The API format is:

POST <BASE_URL>/convert/csv/json

and accepts the following body parameters:

  1. filePath (String)
    1. The absolute file path of the CSV file on your local system. 
  2. options (Object)
    1. [Optional] The various options useful in setting the desired JSON output from the CSV file. The various options are:
      1. delimiter: delimiter used for separating columns. Default value is ",".
      2. quote: If a column contains delimiter, it is able to use quote character to surround the column content. e.g. "hello, world" wont be split into two columns while parsing. Set to "off" will ignore all quotes. Default value is " (double quote)
      3. trim: Indicate if parser trim off spaces surrounding column content. e.g. " content " will be trimmed to "content". Default value is true.
      4. ignoreEmpty: Ignore the empty value in CSV columns. If a column value is not given, set this to true to skip them. Default value is false.
      5. noheader: Indicating csv data has no header row and first row is data row. Default value is false.
      6. headers: An array to specify the headers of CSV data. If --noheader is false, this value will override CSV header row. Default: null. Example: ["my field","name"]. See header row
      7. flatKeys: Don't interpret dots (.) and square brackets in header fields as nested object or array identifiers at all (treat them like regular characters for JSON field identifiers). Default: false.
      8. escape: escape character used in quoted column. Default is double quote (") according to RFC4108. Change to back slash (\) or other chars for your own case.
      9. includeColumns: This parameter instructs the parser to include only those columns as specified by an array of column indexes. Example: [0,2,3] will parse and include only columns 0, 2, and 3 in the JSON output.
      10. ignoreColumns: This parameter instructs the parser to ignore columns as specified by an array of column indexes. Example: [1,3,5] will ignore columns 1, 3, and 5 and will not return them in the JSON output.




  • No labels