polyfill-json-stringify-omit-null-value

1.0.3 • Public • Published

Polyfill - JSON.stringify() - omit null value

Change original JSON.stringify method to omit null values by default

Usage

npm install polyfill-json-stringify-omit-null-value

Then require this script somewhere before all you start using it:

With Javascript:

// with Javascript
require('polyfill-json-stringify-omit-null-value');
const express = require('express');

// with Typescript
import 'polyfill-json-stringify-omit-null-value';
import express from 'express';

When using typescript with ts-node, you can import this directly in tsconfig.json file like this:

{
  "compilerOptions": {},
  "ts-node": {
    "require": [
      "polyfill-json-stringify-omit-null-value"
    ]
  }
}

This polyfill works on both the backend and frontend and works by modifying the JSON.stringify() method so that by default it ignores keys that have a null value

Enjoy!

Package Sidebar

Install

npm i polyfill-json-stringify-omit-null-value

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

5.14 kB

Total Files

6

Last publish

Collaborators

  • leandroluk