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

Support single line pretty-printed JSON output #2344

Closed
Marcono1234 opened this issue Mar 18, 2023 · 0 comments · Fixed by #2345
Closed

Support single line pretty-printed JSON output #2344

Marcono1234 opened this issue Mar 18, 2023 · 0 comments · Fixed by #2345

Comments

@Marcono1234
Copy link
Collaborator

Marcono1234 commented Mar 18, 2023

Problem solved by the feature

When users know in advance that the JSON data to write is rather small, but they still want increased readability, they might not want line breaks but a space after , and :. For example:

{"a": [1, 2, 3], "b": true}

Even with the upcoming FormattingStyle (#2231) this is currently not possible. See also slightly related discussion in #2327 (comment).

Feature description

Extend FormattingStyle with a setting withSpaceAfterSeparator(boolean) (or similar):

  • true: always add a space after :, and in case the newline value of the style is empty, also add a space after ,
  • false: don't add a space after : and ,

Note: This has no effect on the newline value of the style. If the newline is not empty it will still be added after , and no space will be added after the ,, regardless of the withSpaceAfterSeparator value.

Alternatives / workarounds

None?

But maybe this use case is not common enough to justify adding a new FormattingStyle method.

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

Successfully merging a pull request may close this issue.

1 participant