You are mistaken, the white space makes no difference
eg
[{"id":"1c0bb849507f28ad","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test","payloadType":"str","x":170,"y":3260,"wires":[["7ea7f6fecad53836","273f04f42cd37a26"]]},{"id":"7ea7f6fecad53836","type":"template","z":"452103ea51141731","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"transport\": {\n \"host\": \"localhost\",\n \"port\": 587,\n \"auth\": {\n \"user\": \"foo\", \n \"pass\": \"000\"\n }\n },\n \"options\": {\n \"from\": \"test@dom.com\",\n \"to\": \"user@test\",\n \"subject\": \"WARNING\",\n \"text\": \"Device: {{payload}}\"\n }\n}","output":"str","x":320,"y":3260,"wires":[["543d77c6f929e577"]]},{"id":"273f04f42cd37a26","type":"template","z":"452103ea51141731","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"transport\": {\n \"host\": \"localhost\",\n \"port\": 587,\n \"auth\": {\n \"user\": \"foo\", \n \"pass\": \"000\"\n }\n },\n \"options\": {\n \"from\": \"test@dom.com\",\n \"to\": \"user@test\",\n \"subject\": \"WARNING\",\n \"text\": \"Device: {{ payload }}\"\n }\n}","output":"str","x":320,"y":3300,"wires":[["1cd8e2bd56d0b608"]]},{"id":"543d77c6f929e577","type":"debug","z":"452103ea51141731","name":"debug 106","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":3240,"wires":[]},{"id":"1cd8e2bd56d0b608","type":"debug","z":"452103ea51141731","name":"debug 107","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":3300,"wires":[]}]
You can see both formats work in image below
Also if you are using aJSON node, it is not required as template node can output an object.
e.g.
[{"id":"1c0bb849507f28ad","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test","payloadType":"str","x":170,"y":3260,"wires":[["7ea7f6fecad53836"]]},{"id":"7ea7f6fecad53836","type":"template","z":"452103ea51141731","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"transport\": {\n \"host\": \"localhost\",\n \"port\": 587,\n \"auth\": {\n \"user\": \"foo\", \n \"pass\": \"000\"\n }\n },\n \"options\": {\n \"from\": \"test@dom.com\",\n \"to\": \"user@test\",\n \"subject\": \"WARNING\",\n \"text\": \"Device: {{payload}}\"\n }\n}","output":"json","x":320,"y":3260,"wires":[["543d77c6f929e577"]]},{"id":"543d77c6f929e577","type":"debug","z":"452103ea51141731","name":"debug 106","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":3240,"wires":[]}]