Hi,
I want to change the value mydb
of a json object key DbName
to another value without using function node with input as object name and key name.
[{"id":"bcd513be.ed647","type":"function","z":"ee38a730.b7ca38","name":"","func":"\nmsg.data = {DataBase:{IpAddr:'127.0.0.1',Port:'5432',User:'admin',Pass:'Pass',DbName:'mydb'}}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2460,"y":120,"wires":[["744bb926.51df58"]]},{"id":"d7647d4c.b6643","type":"inject","z":"ee38a730.b7ca38","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":2110,"y":120,"wires":[["f1403d50.d4057"]]},{"id":"965aebfc.4106d8","type":"debug","z":"ee38a730.b7ca38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2470,"y":200,"wires":[]},{"id":"f1403d50.d4057","type":"change","z":"ee38a730.b7ca38","name":"","rules":[{"t":"set","p":"objName","pt":"msg","to":"DataBase","tot":"str"},{"t":"set","p":"keyName","pt":"msg","to":"DbName","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2280,"y":120,"wires":[["bcd513be.ed647"]]},{"id":"744bb926.51df58","type":"change","z":"ee38a730.b7ca38","name":"","rules":[{"t":"set","p":"property","pt":"msg","to":"'data.' & msg.objName & '.' & msg.keyName","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":2290,"y":200,"wires":[["965aebfc.4106d8"]]}]
I thought to use change
node in conjunction with using $lookup() function to get value and change, ... but I don't know how to do ...
Any hint will be great.
Thanks.