Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy keys are not forced #30

Open
studer-l opened this issue Apr 6, 2020 · 1 comment
Open

Lazy keys are not forced #30

studer-l opened this issue Apr 6, 2020 · 1 comment

Comments

@studer-l
Copy link

studer-l commented Apr 6, 2020

Given a hashmap with lazy-seq keys, jsonista does not force their evaluation.

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\"]]"
@miikka
Copy link
Contributor

miikka commented Jan 29, 2021

JSON object keys are strings, so the correct result would be like this:

user=> (j/write-value-as-string {'(:key) :value})
"{\"(:key)\":\"value\"}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants