csv2json 0.0.3 copy "csv2json: ^0.0.3" to clipboard
csv2json: ^0.0.3 copied to clipboard

csv2json is a versatile Dart package designed to simplify the conversion of Comma-Separated Values (CSV) data to JavaScript Object Notation (JSON) format.

example/csv2json_example.dart

import 'package:csv2json/csv2json.dart';
import 'dart:async';

Future<void> main() async {
  final csvData = 'name,age\nAlice,30\nBob,25';
  final jsonData = csv2json(csvData);
  print('CSV to JSON:');
  print(
      jsonData); // [{'name': 'Alice', 'age': '30'}, {'name': 'Bob', 'age': '25'}]

  final filePath = 'example/mock_datas.csv';
  final jsonFileData = await csvFileToJson(filePath);
  print('CSV File to JSON:');
  print(jsonFileData); // [{name: John Doe, age: 30}, {name: Jane Doe, age: 25}]

  final inputData = 'name,age\nAlice,30\nBob,25';
  final outputFilePath = 'example/output.json';

  await csvToJsonFile(inputData, outputFilePath);
  print('CSV data converted to JSON and written to $outputFilePath');
}
7
likes
160
points
413
downloads

Publisher

unverified uploader

Weekly Downloads

csv2json is a versatile Dart package designed to simplify the conversion of Comma-Separated Values (CSV) data to JavaScript Object Notation (JSON) format.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on csv2json