I am using libmosquitto and the parson library in a C application running on my IoT device for doing stuff with MQTT and parsing JSON.
When I publish a message to my device using the mosquitto_pub command on a Linux terminal as follows :
mosquitto_pub -t "mytopic/test" -u "admin" -P "admin" -h 192.168.5.100 -m "{"value1": 1, "value2": 2, "value3": 3}"
I am succesfully receiving the message on the device as I am subscribed to it, however, I cannot parse the values at all using json_object_dotget_value
JSON_Value* root_value = json_parse_string(payload);
JSON_Object* root_object = json_value_get_object(root_value);
JSON_Value* value1 = json_object_dotget_value(root_object, "value1");
JSON_Value* value2 = json_object_dotget_value(root_object, "value2");
JSON_Value* value3 = json_object_dotget_value(root_object, "value3");
The values returned are NULL.
I know that i'm leaving out lots of code here. However, the problem is not on the receiving end, because when another application in Python publishes this message, the parsing works fine.
There is something wrong with my mosquitto_pub
command, but I can't see it.
I'd appreciate any help. Thanks.