metosin / jsonista

Clojure library for fast JSON encoding and decoding.
https://cljdoc.org/d/metosin/jsonista
Eclipse Public License 2.0
422 stars 30 forks source link

Serializing with a partially deserialized object #27

Open bsless opened 4 years ago

bsless commented 4 years ago

Hello, Thank you for this great library. I really like it.

I have a particular use case which I wanted to know was possible with jsonista and if so, what I'd have to do:

When using write-value with a byte array as value in a map and reading it back with read-value, it's interpreted as a string and not as the object from which it was read, i.e.

(read-value
 (write-value-as-bytes
  {"b" (write-value-as-bytes {"a" 1})}))
=> {"b" "eyJhIjoxfQ=="}

while the desired output would be {"b" {"a" 1}}.

Do I need to do some hacking on the mapper to make it happen? I tried writing a mapper which would pass a byte-array without change and provide it as a module when creating an object-mapper but it didn't work. Do you have suggestions?

Thanks in advance