1. format-json
A JSON formatter module for various text/plain serialization styles
format-json
Package: format-json
Created by: johan
Last modified: Sat, 18 Jun 2022 03:03:54 GMT
Version: 1.0.3
Downloads: 21,231
Repository: https://github.com/johan/format-json

Install

npm install format-json
yarn add format-json

format-json

A JSON formatter module for various text/plain serialization styles

 > var json = require('format-json');
> var data = {test: "for example", some: [{nested:0, things: []}, {}]};
> console.log(json.diffy(data));
{ "test": "for example"
, "some":
  [ { "nested": 0
    , "things": []
    }
  , {}
  ]
}
> console.log(json.plain(data));
{
  "test": "for example",
  "some": [
    {
      "nested": 0,
      "things": []
    },
    {}
  ]
}
> console.log(json.terse(data));
{"test":"for example","some":[{"nested":0,"things":[]},{}]}

Why?

For short: diffs in version controlled JSON is what prompted json.diffy.

The comma-first style may look wonky at first, but it's a compromise that helps
produce diffs where a change (addition, change or deletion) of one property has
no affect on surrounding lines to reduce the amount of diff noise.

Having used this format for a while now, I also appreciate how you get straight
left margins for Objects and Arrays alike.

Not convinced? Then please don't use it! :-)

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin