Eliminating duplicate keys in an edn file


#1

I’m converting log files into an edn file, converting json to maps, etc. I want the powerful de-duping of maps. Instead, though, it’s simply erroring that there are duplicate keys (which there are – that’s the point). How can I actually dedupe these without meticulously going through each error to find the entry with the duplicate key?


#2

This question is now academic; I solved it outside of Clojure by just emacs-ing it. Still, is there a way of deduping an edn map rather than throwing an error?


#3

The only way I know of would be to customize the source code of an edn reader, e.g. the tools.reader library [1], so that it explicitly allowed duplicate keys rather than throwing an exception as they probably do now, with whatever logic you wanted to use for deciding what to do when collisions occur. Or write your own such code from scratch.

[1] https://github.com/clojure/tools.reader