Open studer-l opened 4 years ago
Given a hashmap with lazy-seq keys, jsonista does not force their evaluation.
lazy-seq
In all other cases that I came up with, lazy-seqs are forced (values in hashmaps, other containers, nested), hence I assume that this is a bug.
See the following repl session:
jsonista.core-test> (j/write-value-as-string {(lazy-seq '(:key)) :value}) ;; bug "{\"clojure.lang.LazySeq@3cd66127\":\"value\"}" jsonista.core-test> (j/write-value-as-string {:key (lazy-seq '(:value))}) ;; correct "{\"key\":[\"value\"]}" jsonista.core-test> (j/write-value-as-string (lazy-seq (list (lazy-seq '(:one))))) ;; correct "[[\"one\"]]" jsonista.core-test> (j/write-value-as-string [(lazy-seq '(:one)) (lazy-seq '(:two))]) ;; correct "[[\"one\"],[\"two\"]]"
JSON object keys are strings, so the correct result would be like this:
user=> (j/write-value-as-string {'(:key) :value}) "{\"(:key)\":\"value\"}"
Given a hashmap with
lazy-seq
keys, jsonista does not force their evaluation.In all other cases that I came up with,
lazy-seq
s are forced (values in hashmaps, other containers, nested), hence I assume that this is a bug.See the following repl session: