Use JSON strings
- Last UpdatedAug 21, 2024
- 1 minute read
Data messages should be in string format. The string can be formatted as a JSON key value pair, which is automatically detected. JSON messages are parsed by the driver to allow the extraction of each key value pair as attributes of an object.
For example, the field device from a pump station transmits a message that includes location, pump running status, oil pressure, and maintenance data. The MQTT topic for this message is Field/FS785/Status. The payload for this message uses a JSON formatted message, such as:
{"lat":32.95646, "lon":-96.82275, "Pump_running":1, “Oil_Press”:67.23, “Maintenance”:"Last Maintenance Dec 14-2015"}
An application can subscribe to any of the following topics:
-
Field/FS785/Status
-
Field/FS785/Status.lat
-
Field/FS785/Status.lon
-
Field/FS785/Status.Pump_Running
-
Field/FS785/Status.Oil_Press
-
Field/FS785/Status.Maintenance