From 6306b0ca1349a2351442ae34a46dc865459d7d83 Mon Sep 17 00:00:00 2001 From: Sleepful Date: Thu, 30 Nov 2023 00:25:30 -0600 Subject: [PATCH] Add example to create JSON string without escaped characters --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 13fb8b8..8732014 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,9 @@ encoders. ;; generate JSON and munge keys with a custom function (generate-string {:foo "bar"} {:key-fn (fn [k] (.toUpperCase (name k)))}) ;; => "{\"FOO\":\"bar\"}" + +;; generate JSON without escaping the characters (by writing it to a file) +(spit "foo.json" (json/generate-string {:foo "bar"} {:pretty true})) ``` In the event encoding fails, Cheshire will throw a `JsonGenerationException`.