1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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

@ -488,7 +488,8 @@
"json": { "json": {
"errors": { "errors": {
"dropped-object": "Ignored non-object payload", "dropped-object": "Ignored non-object payload",
"dropped": "Ignored unsupported payload type" "dropped": "Ignored unsupported payload type",
"dropped-error": "Failed to convert payload"
} }
}, },
"xml": { "xml": {

View File

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