make sure to bind *read-eval* to false when reading arbitrary code from files...

(defn read-back
"Read the file f back on memory. Careful not to eval anything dangerous (#=)."
[f]
(binding [*read-eval* false]
(read-string (slurp f))))

Jim


On 23/08/12 21:32, larry google groups wrote:
(def m {:person {:firstname "john":lastname"doe"}})
(spit "/home/d/m.clj" m)
(read-string (slurp "/home/d/m.clj"))

at repl:

{:person {:firstname "john", :lastname "doe"}}

Good lord! How long has this been going on?



On Thursday, August 23, 2012 9:39:43 AM UTC-4, Denis Labaye wrote:



    On Thu, Aug 23, 2012 at 3:40 AM, larry google groups
    <lawrenc...@gmail.com <javascript:>> wrote:

        Forgive me if this has been asked before. I am a beginner. I
        have a data structure that is composed of maps nested inside
of a map. What is the easiest way to dump this out as XML?

    Why do you want to do that?

    Because if all you want to do is persist data to read it back
    later you could just do :

    (def m {:person {:firstname "john"

    :lastname "doe"}})

    ;; persist on disk
    (spit "/home/d/m.clj" m)

    ;; read back later
    (read-string (slurp "/home/d/m.clj"))

-- You received this message because you are subscribed to the Google
        Groups "Clojure" group.
        To post to this group, send email to clo...@googlegroups.com
        <javascript:>
        Note that posts from new members are moderated - please be
        patient with your first post.
        To unsubscribe from this group, send email to
        clojure+u...@googlegroups.com <javascript:>
        For more options, visit this group at
        http://groups.google.com/group/clojure?hl=en
        <http://groups.google.com/group/clojure?hl=en>


--
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 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

Reply via email to