lancepantz / clj-yaml

YAML encoding and decoding for Clojure via SnakeYAML
Other
91 stars 52 forks source link

feature request: optional parameters for primitives #13

Open trevor opened 11 years ago

trevor commented 11 years ago

Perhaps something like {:native-keywords true :native-symbols true :native-vectors false}

=>  (println (yaml-dump ['a/b/c :d/e/f (symbol "stuff and/or things") (keyword "other and/or widgets")]))

---
- !!clojure.lang.Symbol
  name: c
  namespace: a/b
- !!clojure.lang.Keyword
  name: f
  namespace: d/e
  sym:
    name: f
    namespace: d/e
- !!clojure.lang.Symbol
  name: or things
  namespace: stuff and
- !!clojure.lang.Keyword
  name: or widgets
  namespace: other and
  sym:
    name: or widgets
    namespace: other and
...
  clojure.lang.Keyword
  (encode [data]
    (.substring (str data) 1))

  clojure.lang.Symbol
  (encode [data]
    (str data))
=> (println (yaml-dump ['a/b/c :d/e/f (symbol "stuff and/or things") (keyword "other and/or widgets")]))

---
- a/b/c
- d/e/f
- stuff and/or things
- other and/or widgets
...

(Encoding style similar to cheshire: https://github.com/dakrone/cheshire/blob/6d78a56929f3cb4e925e2d09617465314d3114ba/src/cheshire/generate.clj#L134 )