Antonio Danglar
Antonio Danglar

Reputation: 1

mosquitto bad JSON interpretation subscriber

I am trying to publish a message in JSON via -m with a mosquitto publisher. The problem is that my subscriber receive the JSON message without the "" for every single key... so that the format is not JSON any more. Any solution?

Publisher

Subscriber

I expect something like {"Location":14.647291} etc.

Upvotes: -1

Views: 75

Answers (1)

hardillb
hardillb

Reputation: 59771

Wrap the message payload in single quotes. This will be the shell stripping the quotes.

e.g.

mosquitto_pub -t foo/bar -m '{ "hello": "world" }'

or double quotes and escape the internal ones

mosquitto_pub -t foo/bar -m "{ \"hello\": \"world\" }"

Upvotes: 1

Related Questions