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

BugFix: JSONStateWriter prettyprint output is nolonger minified. #1232

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

Robadob
Copy link
Member

@Robadob Robadob commented Sep 21, 2024

rapidjson's PrettyWriter extends Writer, but methods are non-virtual, leading to the bug which has been resolved.

This fix is the best solution of the bad options (e.g. heavy templating or dual internal writers/std::variant with an if/cast every time a method is called) given this implementation's modular approach to writing.

I have tested this works manually, I have no plans to write a test that parses the output to check whether it's minified or not as it would essentially be an inverse of the parsing rules I've written unless you had ground truths to compare against for a specific input. But you can if that's your prerogative.

JSONLogger does not suffer from the same bug, I have a feeling it was noticed when that was implemented and worked around.

Closes #1231

@Robadob Robadob added the bug label Sep 21, 2024
@Robadob Robadob requested review from ptheywood and mondus September 21, 2024 21:26
@Robadob Robadob self-assigned this Sep 21, 2024
rapidjson's PrettyWriter extends Writer, but methods are non-virtual, leading to former bug.

This fix is best solution of the bad options (heavy templating, dual internal writers).

Closes #1231
@Robadob Robadob force-pushed the bugfix_json_prettyprint branch from dfc6628 to 289ff23 Compare September 21, 2024 21:27
Would have broken if it encounterd an odd number of nested quotes within a string.
Copy link
Member

@ptheywood ptheywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would be prefferred but understandable why you haven't with our current time limitations.

Maybe add it to #1050 so it can be added in the future if time allows?

Otherwise looks sensible and appears to behave as intended under linix via a manual check of test.json.

@mondus
Copy link
Member

mondus commented Oct 1, 2024

This might not support single quotes but is less broken than before so suggest to merge and raise a new bug if it comes up.

@mondus mondus merged commit ed7d1d7 into master Oct 1, 2024
22 checks passed
@mondus mondus deleted the bugfix_json_prettyprint branch October 1, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] JSONStateWriter pretty print feature prints minified.
3 participants