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

Make more effort to stringify sensibly when storing in redis.

This commit is contained in:
Mark Hindess 2014-08-26 15:28:09 +01:00
parent 2d92b44f52
commit 025e4ab6d1

View File

@ -83,6 +83,13 @@ module.exports = function(RED) {
var k = this.key || msg.topic;
if (k) {
if (this.structtype == "string") {
if (Buffer.isBuffer(msg.payload)) {
msg.payload = msg.payload.toString();
} else if (typeof msg.payload === "object") {
msg.payload = JSON.stringify(msg.payload);
} else if (typeof msg.payload !== "string") {
msg.payload = ""+msg.payload;
}
this.client.set(k,msg.payload);
} else if (this.structtype == "hash") {
var r = hashFieldRE.exec(msg.payload);