Handle webscoket item being parseable but not an object better

and add test
This commit is contained in:
Dave Conway-Jones
2019-05-29 12:49:35 +01:00
parent 33e20c9969
commit dc75a5812f
2 changed files with 21 additions and 0 deletions

View File

@@ -178,6 +178,9 @@ module.exports = function(RED) {
if (this.wholemsg) {
try {
msg = JSON.parse(data);
if (typeof msg !== "object" && !Array.isArray(msg) && (msg !== null)) {
msg = { payload:msg };
}
}
catch(err) {
msg = { payload:data };