I have found what I think is anomalous behavior (from what I expected) when changing an element in a context Flow Object Variable that was itself extracted as one object in an array of objects from a object in Context Flow variables.
To explain further as demonstrated in this Flow. We create a array of JSON objects flow.sZones
. From that we extract one object from the array into flow.sZone = flow.sZones.Zone[4]
.
Now I change one element in flow.sZone
to a new value but it also changes the corresponding value in flow.sZones
, it even gets the right element. As demonstrated in flow below I change flow.sZone.Value = 23
but this also changes flow.sZones.Zone[4].Value
to 23.
It is like flow.sZone
is not a separate variable, but a pointer to flow.sZones.Zone[4]
[{"id":"97d95e4.9c88aa","type":"inject","z":"c3c6cf1d.d7dd1","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":124.5,"y":60,"wires":[["50e4695e.fd9688"]]},{"id":"50e4695e.fd9688","type":"change","z":"c3c6cf1d.d7dd1","name":"Reset Array","rules":[{"t":"set","p":"sZones","pt":"flow","to":"{\"Zone\":[{\"Number\":0,\"Name\":\"Zero\",\"Description\":\"D Zero\",\"Value\":4},{\"Number\":1,\"Name\":\"One\",\"Description\":\"D One\",\"Value\":5},{\"Number\":2,\"Name\":\"Two\",\"Description\":\"D Two\",\"Value\":6},{\"Number\":3,\"Name\":\"Three\",\"Description\":\"D Three\",\"Value\":7},{\"Number\":4,\"Name\":\"Four\",\"Description\":\"D Four\",\"Value\":8},{\"Number\":5,\"Name\":\"Five\",\"Description\":\"D Five\",\"Value\":9},{\"Number\":6,\"Name\":\"Six\",\"Description\":\"D Six\",\"Value\":10},{\"Number\":7,\"Name\":\"Seven\",\"Description\":\"D Seven\",\"Value\":11}]}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":326.5,"y":60,"wires":[["9497f5fa.3bb0e8"]]},{"id":"9497f5fa.3bb0e8","type":"change","z":"c3c6cf1d.d7dd1","name":"","rules":[{"t":"set","p":"sZone","pt":"flow","to":"sZones.Zone[4]","tot":"flow"},{"t":"set","p":"sZone.Value","pt":"flow","to":"23","tot":"num"},{"t":"set","p":"sZones","pt":"msg","to":"sZones","tot":"flow"},{"t":"set","p":"sZone","pt":"msg","to":"sZone","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":637,"y":60,"wires":[["827be915.44bbc8"]]},{"id":"827be915.44bbc8","type":"debug","z":"c3c6cf1d.d7dd1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":801.5,"y":60,"wires":[]}]
Latest Nod-Red (1.02) running on up to date W10 (my Sandpit). Context Variables in memory only