Inject node has
{
"metrics": [
{
"name": "testing/test1",
"value": 11
},
{
"name": "testing/test2",
"value": 12
}
]
}
I then use the JSON node to convert to a string
"{"metrics":[{"name":"testing/test1","value":11},{"name":"testing/test2","value":12}]}"
I have an array of a global variable "Globaltag"
[ "DegreeC", "DegreeF", "Motor1", "Start_PB", "Stop_PB" ]
Now I need to replace the name values such as "testing/test1" with the contents of the global variable Globaltag[0]
How do I specify this in a change node? or is there another way to do this? I try this
change msg.payload
search for testing/test1
replace with global."Global[0]"
result is "{"metrics":[{"name":"undefined","value":11}......
I hope for "{"metrics":[{"name":"DegreeC","value":11}
I can manually use a function node and concat like
var Mystring = '{ "metrics": [ {"name": "' + global.get("Globaltag[0]") + .......
This will eventually get fed to a SparkplugB publish node to go to the broker.
Thank you.