mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4900 from hardillb/allow-number-user-properties-mqtt
Allow msg.userProperties to have number values
This commit is contained in:
commit
8988176c22
@ -158,9 +158,16 @@ module.exports = function(RED) {
|
|||||||
if(!keys || !keys.length) return null;
|
if(!keys || !keys.length) return null;
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
let val = srcUserProperties[key];
|
let val = srcUserProperties[key];
|
||||||
if(typeof val == "string") {
|
if(typeof val === "string") {
|
||||||
count++;
|
count++;
|
||||||
_clone[key] = val;
|
_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;
|
if(count) properties.userProperties = _clone;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user