Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove fields from JSON Object

Tags:

node-red

Hi can somebody help removing element from nested json array like this

{
"_id": "ProductionData1",
"_rev": "1-b4a160f5e13fab074d2fcc359e820d3f",
"topic": "",
"payload": {
    "plant Operating Time": "600",
    "plant stop": "10"
    }
}

Lets say I want to remove the object "_id": "ProductionData1" "_rev": "1-b4a160f5e13fab074d2fcc359e820d3f" "topic": "", that should leave me with the following:

{
"payload": {
     "plant Operating Time": "600",
     "plant stop": "10"
     }
}
like image 705
Danial Q Azmi Avatar asked May 23 '26 05:05

Danial Q Azmi


1 Answers

The change node will allow you to remove key value pairs from a the msg object.

enter image description here

From the info sidebar:

Set, change, delete or move properties of a message, flow context or global context.

The node can specify multiple rules that will be applied in turn.

The available operations are:

  • Set - set a property. The value can be a variety of different types, or can be taken from an existing message or context property.
  • Change - search & replace parts of the property. If regular expressions are enabled, the replace with property can include capture groups, for example $1. Replace will only change the type if there is a complete match.
  • Delete - delete a property.
  • Move - move or rename a property.
like image 113
hardillb Avatar answered May 27 '26 19:05

hardillb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!