JSon via MQTT escaping issue

I know I’ve got an escaping issue.

I have thw following json I want to me able to send as the on Commandtopic for mqttv2:

on="{"command":"c:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"},

I’ve left the json as I want it to appear in teh mqtt server.
What escaping do I need to get it to supply the above.
I’ve tried replacing all the internal " with ’ and “” and " to no avail.

Can you show the full configuration? The snippet is certainly missing at least a trailing "…

My first guess would be:

on="{\"command\":\"c:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe\"}",

… though you may need to adjust all your double \\ to quadruple \\\\

Thing mqtt:topic:iotlinkaragorn "IOTLink Aragorn"  (mqtt:broker:mosquitto) @ "Cupboard"
{
	Channels:
		Type switch 	: namovm	"Namo-VM"	[ stateTopic="iotlink/workgroup/aragorn/lwt",
							on="{ command: c:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.ex, args: -Command resume-vm sago-ld, path: c:\\, user: , visible: false, fallback: true }", 
							off="{ command: c:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.ex, args: -Command suspend-vm sago-ld, path: c:\\, user: , visible: false, fallback: true }", 
							commandTopic="iotlink/workgroup/aragorn/commands/run"
							] 
		Type contact	: online		"online"		[ stateTopic="iotlink/workgroup/aragorn/lwt",on="ON", off="OFF"] 
}

It’s for running a powershell command via IOTLink on windows.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.