docs: Add JSON client usage instructions to the README

This commit is contained in:
2025-06-08 10:32:33 -07:00
parent 47371f5e4c
commit 7a4501b3ad
+13
View File
@@ -38,3 +38,16 @@ To disconnect from the broker:
```
For more detailed usage, see the API documentation and the example code in the `examples` directory.
## JSON Client
Milquetoast also provides a JSON client, which automatically parses JSON payloads from received messages and serializes JSON payloads for sent messages.
To connect using the JSON client:
```clojure
(def json-client (milquetoast.api/connect-json! :host "localhost" :port 1883))
```
The JSON client can be used in the same way as the regular client, but note that the payload of received messages will be a map (parsed from the JSON payload), and the payload of sent messages should be a map (which will be serialized to a JSON string).
```