Skip to content

Commit

Permalink
Add example to create JSON string without escaped characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleepful committed Nov 30, 2023
1 parent 9ba8096 commit 6306b0c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 6306b0c

Please sign in to comment.