Confessions and Confusions of a Freelance Fullstacker.

Ashok Mannolu Arunachalam, JavaMosquittoMQTTJSONFix

Mosquitto: was expecting double-quote to start field name

I recently encountered the following exception in my Spring Boot Rest application when I published a MQTT message for a topic.

I was testing the MQTT subscribers whether they get the published message or not.

org.codehaus.jackson.JsonParseException: Unexpected character ('s' (code 110)): was expecting double-quote to start field name

I published the below message:

$ mosquitto_pub -t "/v1/ashkeys/site" -m "{site:""}"

After some googling I found out that field names should be double-quoted.

I know it was obvious from the exception itself. Dumb me >_<

Now the following works just fine with the subscribers.

$ mosquitto_pub -t "/v1/ashkeys/site" -m "{"site":""}"

The MQTT subscribers in turn use the jackson parser which adheres JSON specification. JSON specification demands that field names in a JSON should be double-quoted.