JSPM

polyfill-json-stringify-omit-null-value

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q55233F
  • License ISC

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

Package Exports

  • polyfill-json-stringify-omit-null-value
  • polyfill-json-stringify-omit-null-value/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (polyfill-json-stringify-omit-null-value) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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!