You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Request
When json-c converts a json array to a json string and the flag 'JSON_C_TO_STRING_PRETTY' is used, it inserts a newline after every array element.
If the array is a long array filled with integers, it can be tedious to scroll down to view the entire array.
A good solution would be to use the default flag 'JSON_C_TO_STRING_PLAIN' to print the array all on one line. But if the array is nested within a json object that includes other objects that are not arrays then the 'JSON_C_TO_STRING_PRETTY' flag seems to be needed to preserve the pretty formatting for the other objects.
Would it be possible to have a new pretty-print format that prints n-number of array elements per line? While still preserving pretty format for the non-array objects within an object? So the result would look something like this:
Possible? Theoretically, sure. Possible without hardcoding some arbitrary line length, and while doing something sensible with array elements that aren't simple numbers or strings? Well, that's a bit harder.
The code changes would be around the line that adds the "\n": https://github.com/json-c/json-c/blob/master/json_object.c#L1389, but the exactly logic to decide when to add the newline or not will take some work to figure out.
And, of course, we need some way in the API to specify the line length to use.
If you have some ideas about how this might work feel free to expand and refine on your initial example, above.
This flag is the same as JSON_C_TO_STRING_PRETTY except that arrays will
print up to 15 elements per line instead of just 1 element per line.
This flag only works with elements that are of the json_type null,
boolean, double, or int. Issue json-c#795.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
@hawicz thanks for reviewing this request. I opened the merge request so you can see my thinking, but am open to discussing all of it. TL;DR I hardcoded some arbitrary line length of 15 elements and restricted the flag to array elements that are only of the type null, bool, int or double.
Feature Request
When json-c converts a json array to a json string and the flag 'JSON_C_TO_STRING_PRETTY' is used, it inserts a newline after every array element.
If the array is a long array filled with integers, it can be tedious to scroll down to view the entire array.
A good solution would be to use the default flag 'JSON_C_TO_STRING_PLAIN' to print the array all on one line. But if the array is nested within a json object that includes other objects that are not arrays then the 'JSON_C_TO_STRING_PRETTY' flag seems to be needed to preserve the pretty formatting for the other objects.
Example:
Steps To Reproduce
Would it be possible to have a new pretty-print format that prints n-number of array elements per line? While still preserving pretty format for the non-array objects within an object? So the result would look something like this:
Version and Platform
The text was updated successfully, but these errors were encountered: