Hello not overly familiar with JavaScript quite new to it actually so i pulled bits from other projects and now struggling to wrap things up.
This is for a small RGB lighting project. The json payload message is transported via MQTT and the initial input is a string value as follows "rrr,ggg,bbb".
what i have come up with so far is as follows
(function(i) {
var rgb = i.split(",");
var color = {"r":rgb[0],"g":rgb[1],"b":rgb[2]}
return JSON.stringify({color});
})(input)
Desired result needs to be {"color":{"r":232,"g":200,"b":55}}
the JS gets stored as a .js file and referenced when transformation is needed
any help would be much appreciated.