jsonp-api icon indicating copy to clipboard operation
jsonp-api copied to clipboard

[api] Support x-json-stream, add JsonGenerator writeNewLine()

Open rbygrave opened this issue 2 years ago • 0 comments

Reference: https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON

When looking at JsonGenerator API I do not see a mechanism to support x-json-stream type output using the "Line delimited JSON" format. Is there a way to produce it that I am missing? Otherwise, I would like to discuss and see if that would be something we could look to add?

Background:

I have traditionally been using jackson core JsonGenerator which includes a writeRaw(char) method that I can use to write the new line character.

In general for x-json-stream "line delimited JSON" we need to:

  1. Ensuring "pretty" printing JSON is disabled / turned off
  2. Write \n characters after each top level json object

Ideally I would like to see support for producing this via the JsonGenerator API. I believe that would mean adding a method to JsonGenerator like writeNewLine().

rbygrave avatar Dec 09 '21 08:12 rbygrave