All Projects → rejas → Gulp Json Editor

rejas / Gulp Json Editor

Licence: mit
A gulp plugin to edit JSON objects

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Json Editor

gulp-golang
gulp plugin for golang projects
Stars: ✭ 13 (-76.36%)
Mutual labels:  gulp, gulp-plugin
gulp-convert-encoding
Plugin for gulp to convert files from one encoding to another.
Stars: ✭ 15 (-72.73%)
Mutual labels:  gulp, gulp-plugin
anyfs
Portable file system for Node
Stars: ✭ 17 (-69.09%)
Mutual labels:  gulp, gulp-plugin
gulp-recess
[DEPRECATED] Lint CSS and LESS with RECESS
Stars: ✭ 42 (-23.64%)
Mutual labels:  gulp, gulp-plugin
Gulp Angular Templatecache
Concatenates and registers AngularJS templates in the $templateCache.
Stars: ✭ 530 (+863.64%)
Mutual labels:  gulp, gulp-plugin
gulp-tinypng-compress
TinyPNG API wrapper for compressing PNG & JPG images
Stars: ✭ 49 (-10.91%)
Mutual labels:  gulp, gulp-plugin
Gulp Require Tasks
Splits Gulpfile into multiple individual files
Stars: ✭ 51 (-7.27%)
Mutual labels:  gulp, gulp-plugin
gulp-merge-json
A gulp plugin to merge JSON & JSON5 files into one file
Stars: ✭ 35 (-36.36%)
Mutual labels:  gulp, gulp-plugin
Gulp Pug
Gulp plugin for compiling Pug templates
Stars: ✭ 512 (+830.91%)
Mutual labels:  gulp, gulp-plugin
Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (+761.82%)
Mutual labels:  gulp, gulp-plugin
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-65.45%)
Mutual labels:  gulp, gulp-plugin
Gulp Jsonlint
🔍 jsonlint plugin for Gulp
Stars: ✭ 26 (-52.73%)
Mutual labels:  gulp, gulp-plugin
gulp-esbuild
gulp plugin for esbuild bundler
Stars: ✭ 39 (-29.09%)
Mutual labels:  gulp, gulp-plugin
gulp-iife
A Gulp plugin for wrapping JavaScript code in IIFEs.
Stars: ✭ 39 (-29.09%)
Mutual labels:  gulp, gulp-plugin
gulp-ava
Run AVA tests
Stars: ✭ 56 (+1.82%)
Mutual labels:  gulp, gulp-plugin
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-60%)
Mutual labels:  gulp, gulp-plugin
gulp-sitemap
Generate a search engine friendly sitemap.xml using a Gulp stream
Stars: ✭ 60 (+9.09%)
Mutual labels:  gulp, gulp-plugin
gulp-es6-transpiler
[DEPRECATED] Transpile ES2015 to ES5
Stars: ✭ 47 (-14.55%)
Mutual labels:  gulp, gulp-plugin
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (+38.18%)
Mutual labels:  gulp, gulp-plugin
Panini
A super simple flat file generator.
Stars: ✭ 562 (+921.82%)
Mutual labels:  gulp, json

gulp-json-editor

npm version Build Status

gulp-json-editor is a gulp plugin to edit JSON objects.

Usage

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](https://github.com/beautify-web/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"));

/*
  specify [deepmerge](https://github.com/TehShrike/deepmerge) option
*/
gulp.src("./manifest.json")
  .pipe(jeditor({ 
    "authors": ["tomcat"] 
  },
  // the second argument is passed to js-beautify as its option
  {},
  // the third argument is passed to deepmerge options, eg, arrayMerge options
  { 
    arrayMerge: function (dist,source,options) {return source;} 
  }))
  .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.

Disable beautification

gulp.src("./manifest.json")
  .pipe(jeditor({
    'version': '1.2.3'
  },
  {
    beautify: false
  }))
  .pipe(gulp.dest("./dest"));

API

jeditor(editorObject, [jsBeautifyOptions], [deepmergeOptions])

editorObject

Type: JSON object

JSON object to merge with.

jsBeautifyOptions

Type: object

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

deepmergeOptions

Type: object

This object is passed to deepmerge as its option.

jeditor(editorFunction, [jsBeautifyOptions], [deepmergeOptions])

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.

deepmergeOptions

Type: object

This object is passed to deepmerge as its option.

License

Copyright (c) 2019 rejas

Licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].