I am using the S7-node to get data from SIEMENS PLC I have a huge list of data to take out and I would to recreate an object I tried to name the variable as :
line1.color.value
line1.speed.value
line2.color.value
line2.speed.value
if i try to get the values with msg.payload.line1.color.value is it not working, there is no object corresponding.
I would like to automatically create the objects line1,line2... following the name of the variable. Is there a way to do it ?
1. set function
To implement a 'set' function similar to the one in Lodash, you can use recursion to handle nested properties. Here's a simple JavaScript implementation:
This 'set' function takes the object, the path, and the value to be set as parameters. If the path is a string, it is split into an array of paths. Recursively create nested properties and set the given value at the end of the path.
2. use set function