# gulp-json-transform

> A gulp plugin to transform json files, pipe json files through it and transform them to other json files or other formats.

Latest version **0.5.0** (published 2024-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-json-transform
pnpm add gulp-json-transform
yarn add gulp-json-transform
bun add gulp-json-transform
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2024-02-24 |
| First published | 2014-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.8.4 |
| Dependencies | 5 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Tom Haggie |
| Maintainers | thaggie |
| Keywords | gulp, plugin, transform, json |

## Links

- npm: https://www.npmjs.com/package/gulp-json-transform
- Repository: https://github.com/thaggie/gulp-json-transform
- Issues: https://github.com/thaggie/gulp-json-transform/issues
- npm.io page: https://npm.io/package/gulp-json-transform

## Dependencies (5)

- [vinyl](https://npm.io/package/vinyl.md) ^2.1.0
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [fancy-log](https://npm.io/package/fancy-log.md) ^1.3.2
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^1.0.1
- [plugin-error](https://npm.io/package/plugin-error.md) ^1.0.1

## 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

- 0.5.0 (latest) — 2024-02-24
- 0.4.8 — 2022-01-29
- 0.4.7 — 2019-07-13
- 0.4.6 — 2018-12-05
- 0.4.5 — 2017-10-19
- 0.4.4 — 2017-10-19
- 0.4.3 — 2017-10-19
- 0.4.2 — 2016-07-13
- 0.4.1 — 2016-07-01
- 0.4.0 — 2016-07-01
- 0.3.2 — 2016-05-12
- 0.3.1 — 2016-05-12
- 0.3.0 — 2015-11-02
- 0.2.0 — 2014-11-25
- 0.1.0 — 2014-11-22

## README

gulp-json-transform
===================
[![NPM Version](http://img.shields.io/npm/v/gulp-json-transform.svg?style=flat)](https://www.npmjs.com/package/gulp-json-transform)
[![Build Status](https://travis-ci.org/thaggie/gulp-json-transform.svg)](https://travis-ci.org/thaggie/gulp-json-transform)
[![Dependencies Status](https://david-dm.org/thaggie/gulp-json-transform.svg)](https://david-dm.org/thaggie/gulp-json-transform)


A [gulp](https://github.com/gulpjs/gulp) plugin to transform JSON files, pipe JSON files through it and transform them to other JSON files or other text based formats.


## Usage


First install `gulp-json-transform` as a development dependency:

```shell
npm install gulp-json-transform --save-dev
```

Then, add it to your gulpfile.js:

```javascript
var jsonTransform = require('gulp-json-transform');
```

Then create a task that uses it:

```javascript
gulp.task('do-something', function() {
	gulp.src('./app/**/*.json')
	.pipe(jsonTransform(function(data, file) {
		return {
			foobar: data.foo + file.relative
		};
	}))
	.pipe(gulp.dest('./dist/out/'));
});
```

## API

### jsonTransform(transformFn [, whiteSpace])

#### transformFn
Type: `function`

A function that takes the JSON object and a file object (parameters path, base and relative are exposed) as the input parameters and should return either a string which is written raw to the file, a JSON object which is stringified or a Promise which resolves to a string or a JSON object.

Example structure of the file object:
```
{
  path: 'test/fixtures/input.json',
  relative: 'input.json',
  base: 'test/fixtures'
}
```

#### whiteSpace

Type: `String` or `Number`
Default: `undefined`

JSON.stringify's whitespace attribute for pretty-printing the resulting JSON.
See [MDN docs on JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) for more information.

## License

[MIT License](http://en.wikipedia.org/wiki/MIT_License)

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