How to remove specific fields from JSON?

Describe the issue/error/question

In the following JSON, I need to delete the following fields:

  • TotalTax
  • Amount
  • TaxPercent
  • NetAmountTaxable

The rest of the items should be left as is.

What’s the best way I can accomplish this while leaving the JSON intact (without havin to use a ton of SET nodes to reconstruct it)?

{
   "domain":"QBO",
   "sparse":true,
   "Id":"4376",
   "SyncToken":"1",
   "TxnTaxDetail":{
      "TotalTax":84.01,
      "TaxLine":[
         {
            "Amount":79.89,
            "DetailType":"TaxLineDetail",
            "TaxLineDetail":{
               "TaxRateRef":{
                  "value":"5"
               },
               "PercentBased":true,
               "TaxPercent":5,
               "NetAmountTaxable":1597.8
            }
         },
         {
            "Amount":4.12,
            "DetailType":"TaxLineDetail",
            "TaxLineDetail":{
               "TaxRateRef":{
                  "value":"19"
               },
               "PercentBased":true,
               "TaxPercent":7,
               "NetAmountTaxable":58.8
            }
         }
      ]
   }
}

What is the error message (if any)?

Please share the workflow

The data is coming from an http node connecting to the QuickBooks Online API

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.201.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: K8s

Took me a bit to figure out how to use the new Code node - most of the documentation on the Function node doesn’t work, and I am not skilled at Javascript.

But in the end I was able to figure out a solution!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.