Allow JSON node to handle array type

This commit is contained in:
Dave Conway-Jones
2015-10-02 17:30:23 +01:00
parent 9932d34304
commit 83a3642c0e
2 changed files with 10 additions and 4 deletions

View File

@@ -31,9 +31,14 @@ module.exports = function(RED) {
catch(e) { node.error(e.message,msg); }
}
else if (typeof msg.payload === "object") {
if ((!Buffer.isBuffer(msg.payload)) && (!util.isArray(msg.payload))) {
msg.payload = JSON.stringify(msg.payload);
node.send(msg);
if (!Buffer.isBuffer(msg.payload)) {
try {
msg.payload = JSON.stringify(msg.payload);
node.send(msg);
}
catch(e) {
node.error(RED._("json.errors.dropped-error"));
}
}
else { node.warn(RED._("json.errors.dropped-object")); }
}