1.0.0 • Published 5 years ago

json-min-max v1.0.0

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

json-min-max

json minify and beautify for nodejs or browser

Installation

npm:

$ npm install json-min-max --save

server-side example

const JMM = require('json-min-max');

// minify
fs.readFile('./unminified.json', 'utf8', (err, data) => {
  if (err) throw err;
  console.log(JMM.minify(data));
});

// beautify
fs.readFile('./minified.json', 'utf8', (err, data) => {
  if (err) throw err;
  // default indentation is 2
  console.log(JMM.beautify(data,4));
});

browser example

<script src="./dist/jsonMinMax.min.js">
<script>
// minify
let x = document.getElementById('unminifiedData').value;
console.log(JMM.minify(x));

// beautify
let y = document.getElementById('minifiedData').value
console.log(JMM.beautify(y,2));
</script>