# json-convertor

> This package converts json to csv and xml

Latest version **1.0.2** (published 2023-03-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install json-convertor
pnpm add json-convertor
yarn add json-convertor
bun add json-convertor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-03-24 |
| First published | 2023-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shriansh Agarwal |
| Maintainers | shriansh |
| Keywords | json, csv, xml, convert, parse |

## Links

- npm: https://www.npmjs.com/package/json-convertor
- npm.io page: https://npm.io/package/json-convertor

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-03-24
- 1.0.1 — 2023-03-21
- 1.0.0 — 2023-03-21

## 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
<users>
    <user>
        <name>John</name>
        <age>30</age>
    </user>
    <user>
        <name>Jane</name>
        <age>25</age>
    </user>
    <user>
        <name>Bob</name>
        <age>40</age>
    </user>
</users>
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

---
_Source: https://npm.io/package/json-convertor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
