Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:key-fn no longer works in generate-string? #186

Open
wenxijuji opened this issue Dec 2, 2021 · 1 comment
Open

:key-fn no longer works in generate-string? #186

wenxijuji opened this issue Dec 2, 2021 · 1 comment

Comments

@wenxijuji
Copy link

;; [cheshire "5.10.1"] in project
;; [cheshire.core :as json] in require

;; copied from the github page exmaple
(json/generate-string {:foo "bar"} {:key-fn (fn [k] (.toUpperCase (name k)))})
=> "{\"foo\":\"bar\"}"

@wenxijuji wenxijuji changed the title :key-fn no longer works? :key-fn no longer works in generate-string? Dec 2, 2021
@dakrone
Copy link
Owner

dakrone commented Dec 6, 2021

This is strange to me, when I try it locally it appears to work just fine:

~/src/clj/cheshire (git) abc14504  master [origin/master]
1 » git co 5.10.1 
Note: switching to '5.10.1'.
HEAD is now at df98594 Release 5.10.1
~/src/clj/cheshire (git) df985942  tags/5.10.1
» lein repl
nREPL server started on port 35243 on host 127.0.0.1 - nrepl://127.0.0.1:35243
REPL-y 0.4.4, nREPL 0.6.0
Clojure 1.10.3
OpenJDK 64-Bit Server VM 17.0.1+12-39
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (use 'cheshire.core)
nil

user=> (generate-string {:foo "bar"} {:key-fn (fn [k] (.toUpperCase (name k)))})
"{\"FOO\":\"bar\"}"

How are you using it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants