Hide null values in output from JSON.stringify() Hide null values in output from JSON.stringify() json json

Hide null values in output from JSON.stringify()


You can do something like this:

let x = {  'x1':0,  'x2':null,  'x3':"xyz",   'x4': null}console.log(JSON.stringify(x, (key, value) => {  if (value !== null) return value}))