-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conflict of interest between JSON_C_TO_STRING_SPACED and JSON_C_TO_STRING_PRETTY #429
Comments
First proposal, "if JSON_C_TO_STRING_PRETTY is enabled, JSON_C_TO_STRING_SPACED's object-spacing is ignored (because pretty already provides its own object spacing)":
|
A simpler change would be to just clear the JSON_C_TO_STRING_PRETTY bit at the start of the function. |
Not entirely sure I understand what you're suggesting. |
er.. yeah, never mind my previous comment. |
Nice issue and it could be closed @hawicz |
Long since fixed, closing. |
The goal of JSON_C_TO_STRING_SPACED is to include minimal spacing in the output.
The goal of JSON_C_TO_STRING_PRETTY is to indent the output.
JSON_C_TO_STRING_SPACED's minimal spacing includes spacing inside objects and spacing after colons.
JSON_C_TO_STRING_PRETTY's indenting includes spacing inside objects and newlines.
If you want output which has both minimal spacing and is indented (eg. indenting + space after colon), you need to enable both flags, but this currently causes bad indenting.
Therefore, I propose that if JSON_C_TO_STRING_PRETTY is enabled, JSON_C_TO_STRING_SPACED's object-spacing is ignored (because pretty already provides its own object spacing). Alternatively, JSON_C_TO_STRING_PRETTY could be changed to be a complete subset of JSON_C_TO_STRING_SPACED's minimal spacing, which means it would also have to add a space after the colon.
As implemented right now, there is a strange conflict where pretty is not spacing + indenting, and to get all spacing features, your indenting cannot be done right.
The text was updated successfully, but these errors were encountered: