Read file contents as map
Hi, I have a config file that contains a Clojure map. If I slurp that file it obviously returns a string. Is it possible to return that read file as a map (its original data structure) and not a string? Thanks Paul -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Read file contents as map
If you are sure that the file doesn't contain malicious code you can use: (read-string (slurp file)) On Sunday, January 26, 2014 11:24:30 AM UTC-2, Paul Smith wrote: Hi, I have a config file that contains a Clojure map. If I slurp that file it obviously returns a string. Is it possible to return that read file as a map (its original data structure) and not a string? Thanks Paul -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Read file contents as map
And if you are not sure about that, just use edn-only reader: (require '[clojure.tools.reader.edn :as edn]) (edn/read-string (slurp file)) Dňa nedeľa, 26. januára 2014 17:12:32 UTC+1 mynomoto napísal(-a): If you are sure that the file doesn't contain malicious code you can use: (read-string (slurp file)) On Sunday, January 26, 2014 11:24:30 AM UTC-2, Paul Smith wrote: Hi, I have a config file that contains a Clojure map. If I slurp that file it obviously returns a string. Is it possible to return that read file as a map (its original data structure) and not a string? Thanks Paul -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.