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

Efficient methods for printing JSON #318

Open
armanbilge opened this issue Nov 24, 2021 · 0 comments
Open

Efficient methods for printing JSON #318

armanbilge opened this issue Nov 24, 2021 · 0 comments

Comments

@armanbilge
Copy link
Collaborator

@zarthross continuing our discussion from circe/circe#1855 (comment)

To bikeshed a bit, i was just imaging something of the signature def printToStream[F[_]](json: Json, cs: Charset): Stream[F, Byte] but we could go and do something like def printPipe[F[_]](cs: Charset): Pipe[F, Json, Byte] as well.

For your use case in Feral you would be able to then do printToStream(json).through(fs2.io.writeOutputStream(channel)) or something.

Reason I suggest a different printer implementation is I think having an FS2 native implementation would be able to suspend the encoding of the json better, and just overall work better with FS2 than trying to hack around Appendable

I agree that would certainly be a feature worth having. But unfortunately it doesn't address my use case. The problem with a printToStream(json).through(fs2.io.writeOutputStream(channel)) is that instead of printing the Json directly to the output stream, it goes through an intermediate representation of Chunk[Byte] which is exactly what I'm trying to avoid :)

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

No branches or pull requests

1 participant