jsoncpp icon indicating copy to clipboard operation
jsoncpp copied to clipboard

Provide facility for large arrays to be output over long multiple lines

Open JamesH65 opened this issue 11 years ago • 2 comments

When you have a large array (let's say 1000 integers) that needs to be written out, it will be written out one int per line. It would be very useful to be able to specify how many items (or a max line length) are output per line to improve formatting and remove the need for a lot of CR's

e.g, with a max items per line of 10

{ "array" : [ 0,1,2,3,4,5,6,7,8,9 10,11,12,13,14,15,16,17,18,19 20,21,22,23,24,25,26,27,28,29 ], }

JamesH65 avatar Aug 20 '15 14:08 JamesH65

On Thursday, August 20, 2015, JamesH65 [email protected] wrote:

When you have a large array (let's say 1000 integers) that needs to be written out, it will be written out one int per line. It would be very useful to be able to specify how many items (or a max line length) are output per line to improve formatting and remove the need for a lot of CR's

e.g, with a max items per line of 10

{ "array" : [ 0,1,2,3,4,5,6,7,8,9 10,11,12,13,14,15,16,17,18,19 20,21,22,23,24,25,26,27,28,29 ], }

it's not the count per line that matters, is it? If you want tabular format, you should probably use space-padding to make nice even columns. Then the count per line is fixed, sure. If you just want maximal bin-packing to a column limit, do that, sure. These are both slightly different from just having a fixed number of elements per row, though. Just having a fixed number of elements leaves jagged fields that might as well have been bun-packed.

— Reply to this email directly or view it on GitHub https://github.com/open-source-parsers/jsoncpp/issues/335.

ǝnɥɐuop ʎllıq

BillyGoto avatar Aug 20 '15 16:08 BillyGoto

The problem is that if, for example, I have 1000 numbers, they take up 1000 lines (with an extra 1000 carriage returns). I need to spread the load over multiple lines. Could be #items per line, could be a max line length, could be tabular, could be jagged. Doesn't matter. Just needs to make the #lines used somewhat saner.

JamesH65 avatar Aug 21 '15 08:08 JamesH65