From 7a4501b3ad5d7deb6431d3e66f1ea045584a0d25 Mon Sep 17 00:00:00 2001 From: "niten\" (aider)" Date: Sun, 8 Jun 2025 10:32:33 -0700 Subject: [PATCH] docs: Add JSON client usage instructions to the README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 54d8074..6ec38e3 100644 --- a/README.md +++ b/README.md @@ -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). +```