Merge pull request #4900 from hardillb/allow-number-user-properties-mqtt

Allow msg.userProperties to have number values
This commit is contained in:
Nick O'Leary
2024-10-09 10:28:55 +01:00
committed by GitHub

View File

@@ -158,9 +158,16 @@ module.exports = function(RED) {
if(!keys || !keys.length) return null;
keys.forEach(key => {
let val = srcUserProperties[key];
if(typeof val == "string") {
if(typeof val === "string") {
count++;
_clone[key] = val;
} else if (val !== undefined && val !== null) {
try {
_clone[key] = JSON.stringify(val)
count++;
} catch (err) {
// Silently drop property
}
}
});
if(count) properties.userProperties = _clone;