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

pretty dimensional array #1040

Open
wants to merge 12 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@Xilinxx

Xilinxx commented Aug 11, 2017

While working with a 3D array I found the neat kFormatSingleLineArray option. Anyhow this was not more human-readable than the Default setting and so I created the add-on kFormatPretty2DArray which will limit the print to 1 array per line.

kFormatDefault (one item per line)

"{
  "ThreeDim": [
    [
      [
        32426,
        2,
        0,
        0,
        0,

kFormatSingleLineArray (Neat but human unreadable for large arrays)

"TwoDim": [[11, 12, 13, 14], [21, 22, 23, 24]]

New:
kFormatPretty2DArray (limits the format to one array per line and is better human readable.)

"TwoDim": [[11, 12, 13, 14],
    [21, 22, 23, 24]] 
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 11, 2017

Coverage Status

Coverage decreased (-0.07%) to 99.852% when pulling c77b05e on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 11, 2017

Coverage Status

Coverage decreased (-0.07%) to 99.852% when pulling c77b05e on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

@miloyip

This comment has been minimized.

Show comment
Hide comment
@miloyip

miloyip Aug 13, 2017

Collaborator

Besides the failure in CI, I think that "2D" seems a special case, not a general way to deal with.

Collaborator

miloyip commented Aug 13, 2017

Besides the failure in CI, I think that "2D" seems a special case, not a general way to deal with.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 14, 2017

Coverage Status

Coverage decreased (-0.07%) to 99.852% when pulling 1bd2f41 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 14, 2017

Coverage Status

Coverage decreased (-0.07%) to 99.852% when pulling 1bd2f41 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 14, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling 0ab7ee7 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 14, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling 0ab7ee7 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

@Xilinxx

This comment has been minimized.

Show comment
Hide comment
@Xilinxx

Xilinxx Aug 14, 2017

@miloyip - Can you explain me how you would do it in a General way?
I can think of a SetIdentArray['\n','\n','\t'] -> Changing the ident based on the depth of the array...
I'd like to get this change in because I hate maintaining the buildroot patch I have now.
The goal is "human readability of multidimensional arrays". Thanks in advance!

Xilinxx commented Aug 14, 2017

@miloyip - Can you explain me how you would do it in a General way?
I can think of a SetIdentArray['\n','\n','\t'] -> Changing the ident based on the depth of the array...
I'd like to get this change in because I hate maintaining the buildroot patch I have now.
The goal is "human readability of multidimensional arrays". Thanks in advance!

@pah

At least, please get rid of the local static to avoid threading issues.

Secondly, I think nested objects within an array also constitute a "depth change", even if they are fully completed already when reaching EndArray(). Having multi-line objects inside a single-line array will also look weird.

Last, but not least, how does you proposal render "mixed" arrays in general?

  [ 1, [2, 3], 4, 5, [6, 7], 8 ]

To me, an ideal formatting would be to have only leaf arrays (i.e. not containing arrays or objects) on a single line:

 [ 1,
   [2,3],
   4,
   5,
   [6,7],
   8 ]

As this might be hard to achieve without backtracking, a newline before a new nesting level might help a bit:

 [ 1,
   [2,3],
   4,5,
   [6,7],
   8 ]
Show outdated Hide outdated include/rapidjson/writer.h Outdated
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 14, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling c5087e6 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 14, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling c5087e6 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

Show outdated Hide outdated include/rapidjson/writer.h Outdated
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 15, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling 031f742 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 15, 2017

Coverage Status

Coverage decreased (-0.06%) to 99.857% when pulling 031f742 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 15, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.796% when pulling 6c71ec7 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

coveralls commented Aug 15, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.796% when pulling 6c71ec7 on Xilinxx:prettyDimArray into f05edc9 on miloyip:master.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Sep 29, 2017

Coverage Status

Changes Unknown when pulling 81db5f5 on Xilinxx:prettyDimArray into ** on Tencent:master**.

coveralls commented Sep 29, 2017

Coverage Status

Changes Unknown when pulling 81db5f5 on Xilinxx:prettyDimArray into ** on Tencent:master**.

pretty dimensional array
use namespace

make _CXX11=OFF compile

static int removed

all modification in prettywriter.h

SetFormatOptions OR function removed

example prettyarray cleanup

tidy example
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Nov 8, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.797% when pulling 2f888b1 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

coveralls commented Nov 8, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.797% when pulling 2f888b1 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Nov 8, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.797% when pulling 2f888b1 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

coveralls commented Nov 8, 2017

Coverage Status

Coverage decreased (-0.1%) to 99.797% when pulling 2f888b1 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

@Xilinxx

This comment has been minimized.

Show comment
Hide comment
@Xilinxx

Xilinxx Dec 12, 2017

@miloyip , is there anything I should do to get this Pull-request merged in? (No Idea how I can get the coverage increased...)

Xilinxx commented Dec 12, 2017

@miloyip , is there anything I should do to get this Pull-request merged in? (No Idea how I can get the coverage increased...)

@miloyip

This comment has been minimized.

Show comment
Hide comment
@miloyip

miloyip Dec 12, 2017

Collaborator

I have 3 concerns:

  1. Is this general enough for 3D or mixed arrays as mentioned by @pah ?
  2. Coverage was decreased as no unit tests are done for the new option.
  3. An additional member variable will occupy extra memory even if this option is not used.

I think the first is of higher priority than the others.

Collaborator

miloyip commented Dec 12, 2017

I have 3 concerns:

  1. Is this general enough for 3D or mixed arrays as mentioned by @pah ?
  2. Coverage was decreased as no unit tests are done for the new option.
  3. An additional member variable will occupy extra memory even if this option is not used.

I think the first is of higher priority than the others.

@Xilinxx

This comment has been minimized.

Show comment
Hide comment
@Xilinxx

Xilinxx Dec 12, 2017

@miloyip ,

  1. it's like @pah shows in his last example: a DepthChange of the array triggers a newline. A mixed array will be printed on the same line. The "kFormatPretty2DArray" seems the most human readable format which is not present. So I dare to say it is general enough to get it in. (I'm using buildroot and would like to get rid of my local patch.)
  2. I'll have a look at the unit tests to fix coverage! Thanks for pointing.
  3. The 'Leaf' strategy of printing arrays would take more than 1 additional member. A small sacrifice.

Xilinxx commented Dec 12, 2017

@miloyip ,

  1. it's like @pah shows in his last example: a DepthChange of the array triggers a newline. A mixed array will be printed on the same line. The "kFormatPretty2DArray" seems the most human readable format which is not present. So I dare to say it is general enough to get it in. (I'm using buildroot and would like to get rid of my local patch.)
  2. I'll have a look at the unit tests to fix coverage! Thanks for pointing.
  3. The 'Leaf' strategy of printing arrays would take more than 1 additional member. A small sacrifice.

Xilinxx added some commits Dec 22, 2017

Merge branch 'prettyDimArray' of https://github.com/Xilinxx/rapidjson
…into prettyDimArray

Conflicts:
	example/prettyarray/prettyarray.cpp
@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Dec 22, 2017

Coverage Status

Coverage increased (+0.003%) to 99.919% when pulling d8c1514 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

coveralls commented Dec 22, 2017

Coverage Status

Coverage increased (+0.003%) to 99.919% when pulling d8c1514 on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Dec 22, 2017

Coverage Status

Coverage increased (+0.003%) to 99.919% when pulling 1d3be5c on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

coveralls commented Dec 22, 2017

Coverage Status

Coverage increased (+0.003%) to 99.919% when pulling 1d3be5c on Xilinxx:prettyDimArray into 17ae6ff on Tencent:master.

@miloyip miloyip added the enhancement label Jun 21, 2018

@miloyip miloyip added this to the v1.2 Beta milestone Jun 21, 2018

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