debitoor / safe-json-stringify

A wrapper for JSON.stringify that handles circular references and prevent defined getters from throwing errors.
https://www.npmjs.com/package/safe-json-stringify
56 stars 16 forks source link

How to use this package in Angular 4 Application ? #11

Open RaviGprec opened 6 years ago

RaviGprec commented 6 years ago

Simply const safeJsonStringify = require('safe-json-stringify'); doesn't work in Angular 4. Because we have import statements in Angular 2, 4+ vesrion. require() is not supported any more. If stringify is exported as class then we can import that class in Angular 4.

Could you tell me "Is it supported for this Angular 4 application ?". If yes, tell me how to use it.

Thanks inadvance!!

gmaughan commented 4 years ago

If it is still relevant for you, the following works for me:

import * as safeJsonStringify from 'safe-json-stringify';

const s = safeJsonStringify(obj);