Search code examples
databasetemplatesinsertnode-red

Node-Red proper formatted output with template


I try do apply a template in node-red to generate a DB INSERT statement. One value to insert is a JSON-string.

if I apply inside template INSERT ... VALUES ('{{time}}','{{data}}' ... and display it in console I see:

INSERT INTO fuere4bfi.soma(itime,data,url) VALUES ('2020-03-25 10:03:33.651', '{"Name":"Default","IsValid":true,"TimeStamp":-1,"AverageTemperature":96.3067853411676,"WallTemperature":150.415780138639,"Matrix":[[150.4,150.4,150.4,150.4,...

How can I get rid of the "?

If I do the same without template, I get:

INSERT INTO fuere4bfi.soma(itime,data,url) VALUES ('2020-03-25 10:06:16.854', '{"Name":"Default","IsValid":true,"TimeStamp":-1,"AverageTemperature":96.3067853411676,"WallTemperature":150.415780138639,"Matrix":[[150.4,150.4,150.4,...

and this is what I need.


Solution

  • I assume you are using a Template node using the mustache formatting.

    By default, the mustache template format will escape any special HTML characters. To stop that behaviour you use {{{triple-brackets}}}.