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:
parent
9932d34304
commit
83a3642c0e
@ -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": {
|
||||||
|
@ -31,9 +31,14 @@ 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)) {
|
||||||
msg.payload = JSON.stringify(msg.payload);
|
try {
|
||||||
node.send(msg);
|
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")); }
|
else { node.warn(RED._("json.errors.dropped-object")); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user