-
Notifications
You must be signed in to change notification settings - Fork 30
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
write-value
closes the object
#61
Comments
Workaround for now (credit @jarohen) (do
(let [obj-mapper (doto (jsonista.core/object-mapper)
(.disable (into-array com.fasterxml.jackson.core.JsonGenerator$Feature [com.fasterxml.jackson.core.JsonGenerator$Feature/AUTO_CLOSE_TARGET])))]
(with-open [out (io/output-stream "/tmp/foo.json")
wrt (io/writer out)]
(jsonista.core/write-value wrt {"foo" 1} obj-mapper)
(.write wrt "\n")
(jsonista.core/write-value wrt {"bar" 1} obj-mapper)))
(slurp "/tmp/foo.json")) |
Could add it into the
(Happy to raise a PR or have you guys add it in, whatever's easier for you 🙂) |
There is now a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Writing to an object in a streaming fashion is a typical use case and since Jsonista aims for performance, supporting that is rather expected. As opposed to using
write-value-as-string
orwrite-value-as-bytes
and then copying the result to an object like a writer.Currently, this is not possible since
write-value
closes the given object, hence an exception is thrown. Or maybe is it Jackson itself?I realized this while trying to write a line-delimited JSON file.
The text was updated successfully, but these errors were encountered: