Forum Discussion

ajs's avatar
ajs
New Contributor II
3 years ago
Solved

Remove JSON Key when value is "" or null

I have a json [ { "opportunity_Id": "Abc1", "sales_account_id": "Abc2", "account_name": "Pitney Bowes Inc.", "city": "Shelton", "address": "27 Waterview Dr", "requested_b...
  • alchemiz's avatar
    alchemiz
    3 years ago

    Hi @ajs,

    Here’s another approached a string manipulation using regex 🙂

    JSON.parse(JSON.stringify($).replace(/"\w+":"",|"\w+":null,|,"\w+":""|,"\w+":null|"\w+":""|"\w+":null/g,'').replace(/\{\},/g,''))
    

    Incoming document

    result after doing some string manipulation

    Thanks,
    MM