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

Feature request: Add interface for Representer #133

Open
conao3 opened this issue Aug 26, 2024 · 0 comments
Open

Feature request: Add interface for Representer #133

conao3 opened this issue Aug 26, 2024 · 0 comments

Comments

@conao3
Copy link

conao3 commented Aug 26, 2024

I notice dumping clojure symbol using clj-yaml, it output !!clojure.lang.Symbol.

user> (require '[clj-yaml.core :as yaml])
user> (yaml/generate-string {:arglists '([] [x])})
"arglists:\n- []\n- - !!clojure.lang.Symbol {}\n"

I want that it just outputs as a string.

My assumption would be an API like this

(yaml/generate-string {:arglists '([] [x])} {:dumper-options :serialize-tag {clojure.lang.Symbol str}})

workaround

thanks @lread

(require '[clj-yaml.core :as yaml]
         '[clojure.walk :as walk])

(defn prep [form]
  (walk/prewalk (fn [item] (if (symbol? item)
                             (str item)
                             item))
                form))

(-> {:arglists '([] [x])} prep yaml/generate-string)
;; => "arglists:\n- []\n- [x]\n"

pointer

from @lread's comment, maybe this feature is Representer of SnakeYAML.

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

1 participant