0.0.5 • Published 3 years ago
@spring-global/spring-data-converter v0.0.5
Spring Data Converter
Converts a Json object array into a specific file format.
Supported Formats
- Currently the only supported format is csv.
Example
Using the generic converter:
import { GenericConverter } from "@spring-global/spring-data-converter";
const users = [
{"name": "John", "age": 30},
{"name": "Robert", "age": 35},
{"name": "Steven", "age": 70},
]
const converter: GenericConverter = new GenericConverter(users, "csv");
const outfile: string = converter.convert();
console.log(outfile);
Alternatively, you can use a specific converter instance like CsvConverter:
import { CsvConverter } from "@spring-global/spring-data-converter";
const csvConverter = new CsvConverter(users);
const outfile: string = csvConverter.convert();
console.log(outfile);
For more flexibility, is recommended to use the GenericConverter instead of specific converters.
Remarks
- The column structure in the output file will be generated based on the first row of the json array.