repl> (-> root zip/down zip/right)
[{:answer-keys [5 6], :id 3} {:l [{:id 2, :answer-keys []}], :pnodes [{:answer-keys [2 3 4], :id 1}], :ppath nil, :r ({:answer-keys [7], :id 4})}]
当我在repl上打印拉链时,我看到了这些数据。我想这可能是我需要序列化拉链的所有数据?提供的数据是否可以反序列化成拉链?
我正在寻找像下面想象的zip/serialize和zip/deserialize函数。
(def s (zip/serialize (-> root zip/down zip/right))) ;; s is a string
(def d (zip/deserialize s)) ;; d is a zipper location
;;And I can go on using the deserialized zipper d without any difficulty.
有人知道如何做到这一点吗?
(涉及IT技术)
print
函数族是为人类阅读而设计的,而不是用于序列化。例如,字符串和符号打印相同,因此会丢失信息。相反,请使用pr-str
,它会以计算机友好的格式进行打印(并且与read-string
函数几乎相反)。 - amalloyprint-string
将一个值打印到字符串中,而read-string
从字符串中读取一个值。 - amalloy