Hello @E1cid, I cannot apply any substitutions, like d_type.replace(/\s/g, ""), because the response from DB doesn't contain any backslash. The backslash is applied by http response node.
This is the d_type field from the database:
{"type":[ {"int_status":"battery","unit":"volt" }, {"sensor":"soil_temperature","unit":"celsius"}, {"sensor":"soil_moisture","unit":"relative"}, {"sensor":"soil_conductibility","unit":"uS/cm"} ] }
And this is the row generated on the web page if no function is applied
"{"type":[ {"int_status":"battery","unit":"volt" }, {"sensor":"soil_temperature","unit":"celsius"}, {"sensor":"soil_moisture","unit":"relative"}, \t{"sensor":"soil_conductibility","unit":"uS/cm"} ] }"
So, I'm not able to intercept the backslash.
This is my flow
[{"id":"b9015c26d1d51798","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"1d0e1490ef317d6c","type":"mysql","z":"b9015c26d1d51798","mydb":"ebec0657.5b765","name":"db","x":430,"y":120,"wires":[["98cc67b0a2d93966","39a538b0e9779581","198535fe79e3c241"]]},{"id":"86f57b27a47dc656","type":"http in","z":"b9015c26d1d51798","name":"","url":"/devices","method":"get","upload":false,"swaggerDoc":"","x":90,"y":120,"wires":[["f18d73f0cd5e27a8"]]},{"id":"f18d73f0cd5e27a8","type":"template","z":"b9015c26d1d51798","name":"SQL Query","field":"topic","fieldType":"msg","format":"handlebars","syntax":"plain","template":"SELECT d_id, d_netDevID, d_alias, d_pos, d_mobile, d_descr, (d_type) FROM `Devices` WHERE 1;","output":"str","x":270,"y":120,"wires":[["1d0e1490ef317d6c"]]},{"id":"198535fe79e3c241","type":"http response","z":"b9015c26d1d51798","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":870,"y":120,"wires":[]},{"id":"98cc67b0a2d93966","type":"debug","z":"b9015c26d1d51798","name":"DB-response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":200,"wires":[]},{"id":"a749a9fb73913f22","type":"debug","z":"b9015c26d1d51798","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":260,"wires":[]},{"id":"39a538b0e9779581","type":"function","z":"b9015c26d1d51798","d":true,"name":"lontext to json","func":"var str;\nvar pl = msg.payload;\n// just d_type is text\nfor (var i = 0; i < pl.length; i++){\n node.log(i);\n str = pl[i].d_type;\n node.log(str);\n pl[i].d_type = JSON.parse(str);\n}\n\n//msg.payload = pl.lenght;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":80,"wires":[["a749a9fb73913f22","198535fe79e3c241"]],"info":"**Convert MySql JSON (In fact a string) to json object**"},{"id":"ebec0657.5b765","type":"MySQLdatabase","name":"","host":"10.0.0.114","port":"3306","db":"sensors","tz":"","charset":""}]
This image is the screenshot of the web page.