Open trevor opened 11 years ago
This allows for Sets that contain numbers only, or strings only:
clojure.lang.PersistentHashSet
(encode [data]
(java.util.HashSet. data))
clojure.lang.PersistentTreeSet
(encode [data]
(java.util.TreeSet. data))
… but this is better:
clojure.lang.IPersistentSet
(encode [data]
(into #{}
(map encode data)))
example (with modified fn's):
=> (println (yaml-dump ["y" #{"d" 'b/c :a 2 [3 4 {5 6 :x [7 #{}]}]} "m" nil "n"]))
---
- y
- !!set
a: null
2: null
? - 3
- 4
- 5: 6
x:
- 7
- !!set {}
: null
d: null
? !!clojure.lang.Symbol
name: c
namespace: b
: null
- m
- null
- n
...