# gulp-json-edit

> An updated gulp plugin to edit JSON object

Latest version **2.2.5** (published 2018-01-24) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.2.5 |
| Published | 2018-01-24 |
| First published | 2018-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kazuhiro Nakae |
| Maintainers | viral810 |
| Keywords | gulpplugin, gulp, json |

## Links

- npm: https://www.npmjs.com/package/gulp-json-edit
- Repository: https://github.com/viral810/gulp-json-editor
- Issues: https://github.com/viral810/gulp-json-editor/issues
- npm.io page: https://npm.io/package/gulp-json-edit

## Dependencies (5)

- [through2](https://npm.io/package/through2.md) ~2.0.3
- [deepmerge](https://npm.io/package/deepmerge.md) ~0.2.7
- [js-beautify](https://npm.io/package/js-beautify.md) ~1.5.4
- [plugin-error](https://npm.io/package/plugin-error.md) ^0.1.2
- [detect-indent](https://npm.io/package/detect-indent.md) ^2.0.0

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

- 2.2.5 (latest) — 2018-01-24
- 2.2.4 — 2018-01-23
- 2.2.3 — 2018-01-23
- 2.2.2 — 2018-01-23

## README

# gulp-json-editor

gulp-json-editor is a [gulp](https://github.com/wearefractal/gulp) plugin to edit JSON object.

## Usage
```javascript
var jeditor = require("gulp-json-editor");

/*
  edit JSON object by merging with user specific object
*/
gulp.src("./manifest.json")
  .pipe(jeditor({
    'version': '1.2.3'
  }))
  .pipe(gulp.dest("./dest"));

/*
  edit JSON object by using user specific function
*/
gulp.src("./manifest.json")
  .pipe(jeditor(function(json) {
    json.version = "1.2.3";
    return json; // must return JSON object.
  }))
  .pipe(gulp.dest("./dest"));

/*
  specify js-beautify option
*/
gulp.src("./manifest.json")
  .pipe(jeditor({
    'version': '1.2.3'
  },
  // the second argument is passed to js-beautify as its option
  {
    'indent_char': '\t',
    'indent_size': 1
  }))
  .pipe(gulp.dest("./dest"));
```

### Note
In case of such above situation, all of comment and whitespace in source file is **NOT** kept in destination file.

## API
### jeditor(editorObject, [jsBeautifyOptions])
#### editorObject
Type: `JSON object`

JSON object to merge with.

#### jsBeautifyOptions
Type: `object`

This object is passed to js-beautify as its option.

### jeditor(editorFunction, [jsBeautifyOptions])
#### editorFunction
Type: `function`

The `editorFunction` must have the following signature: `function (json) {}`, and must return JSON object.

#### jsBeautifyOptions
Type: `object`

This object is passed to js-beautify as its option.

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

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