docs: Add JSON client usage instructions to the README
This commit is contained in:
@@ -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).
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user