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

ENH: Add Context.jsonStream(...) to write x-json-stream content from Stream<E> or Iterator<E> #21

Closed
rbygrave opened this issue Jun 16, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rbygrave
Copy link
Contributor

  /**
   * Write the stream as a JSON stream with new line delimiters
   * {@literal application/x-json-stream}.
   *
   * @param stream The stream of beans to write as json
   */
  <E> Context jsonStream(Stream<E> stream);

  /**
   * Write the stream as a JSON stream with new line delimiters
   * {@literal application/x-json-stream}.
   *
   * @param iterator The iterator of beans to write as json
   */
  <E> Context jsonStream(Iterator<E> iterator);

Note that when using Iterator internally it will check if the instance implements AutoCloseable and if so will close the iterator when all elements have been written. Stream implements AutoCloseable so that also gets closed.

@rbygrave rbygrave added the enhancement New feature or request label Jun 16, 2021
@rbygrave rbygrave added this to the 1.6 milestone Jun 16, 2021
@rbygrave rbygrave self-assigned this Jun 16, 2021
rbygrave added a commit that referenced this issue Jun 16, 2021
@rbygrave
Copy link
Contributor Author

FYI @tipsy ... pretty sure you saw this but just in case. Right now I don't quite have time at the moment to prepare a PR for Javalin for this but let me know and tag me on a issue if/when we create one in Javalin.

Cheers, Rob.

@tipsy
Copy link
Collaborator

tipsy commented Jun 17, 2021

@rbygrave It's a nice feature, I'll create an issue :)

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

No branches or pull requests

2 participants