Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shriansh2002/json-convertor
This package converts json to csv and xml
https://github.com/shriansh2002/json-convertor
convert csv json npm npm-package parse xml yarn
Last synced: 4 days ago
JSON representation
This package converts json to csv and xml
- Host: GitHub
- URL: https://github.com/shriansh2002/json-convertor
- Owner: Shriansh2002
- License: mit
- Created: 2023-03-21T05:13:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-24T08:28:20.000Z (almost 2 years ago)
- Last Synced: 2024-12-13T15:54:55.376Z (about 2 months ago)
- Topics: convert, csv, json, npm, npm-package, parse, xml, yarn
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/json-convertor
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON to CSV and XML Converter
This is a Node.js package that allows you to convert JSON data to CSV and XML formats. It is easy to use and can be integrated into your Node.js projects with just a few lines of code.
## Installation
You can install this package using the npm package manager. Open a terminal window and run the following command:
```bash
npm install json-convertor
```## Usage
To use this package in your Node.js project, first require it at the top of your file:
```javascript
const Converter = require('json-convertor');
```## Converting JSON to CSV
To convert JSON data to CSV format, call the convertToCsv function, passing in the JSON data as a parameter:
```javascript
const jsonData = [
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 },
{ name: 'Bob', age: 40 },
];
const csvData = convertToCsv(jsonData);
console.log(csvData);
```This will output the following CSV data:
```excel
"name", "age"
"John", 30
"Jane", 25
"Bob", 40
```## Converting JSON to XML
To convert JSON data to XML format, call the convertToXml function, passing in the JSON data as a parameter:
```javascript
const jsonData = {
users: [
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 },
{ name: 'Bob', age: 40 },
],
};
const xmlData = convertToXml(jsonData);
console.log(xmlData);
```This will output the following XML data:
```xml
John
30
Jane
25
Bob
40
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details