Replies: 3 comments 4 replies
-
|
It seems that all expanded cases in example 2.x are improvements for the expanded cases in 1.x. For the complications expressed in 3.x, I'm not sure if there's a great universal solution (I certainly don't have one), but it seems that long property names will always be a potential problem. (You can ignore my spacing preference around colons here.) |
Beta Was this translation helpful? Give feedback.
-
|
And thinking on this further - when looking over a formatted document, I think my strong preference is for consistency. Even if it's a little weird, it's better to be consistently weird. When scanning JSON knowing the pattern applied to the document makes finding the values and understanding the structure easier. So of any of the above examples, I always end up favoring the consistent ones. This makes 1.1, 2.1, 2.2, 2.3, and 3.3 the most appealing, and I believe the behaviors there would be most useful as a default. Although for 1.1, I think doing this makes it easier to see what's going on (lining up colons with padding so it looks more table-ish): Or maybe even ordering objects and object properties such that as many columns are moved to the front as possible, lining up as many as possible together, although I consider this a totally-optional-nice-to-have: |
Beta Was this translation helpful? Give feedback.
-
|
Implemented in version 5. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a change for version 5 to how object properties are handled for the "expanded" case. I'd like opinions from FracturedJson's users on how it should work: settings, defaults, etc.
Background
In version 4, if a collection is formatted as a table, the property values are already lined up, with the colons all in a row.
Example 1.1
When they're written as "expanded" instead of table-formatted, they're not lined up. The values start immediately after the prop name and colon.
Example 1.2
Even when there's only one column, FracturedJson 4 will treat objects as tables if the values are all the same type, but will fall back to expanded behavior if the types are mixed. This sometimes leads to some visually unpleasant cases. For example, in the case below, Vera and Dave's property values are all aligned, but Chuck's aren't since his zipcode is a number instead of string.
Example 1.3
Proposed Change
The change I'm considering is to align the property values in the expanded case as well. In most cases this makes things look nicer.
Example 2.1
Example 2.2
Example 2.3
Complications
This approach starts to look ugly when the property names are long. Consider this case.
Example 3.1 (Old behavior, MaxTotalLineLength=80)
Example 3.2 (Old behavior, MaxTotalLineLength=120)
Example 3.3 (New behavior, MaxTotalLineLength=80)
Example 3.4 (New behavior, MaxTotalLineLength=120)
For this data, in my opinion, the old behavior (Example 3.1 & 3.2) looks best. And notice that the new behavior prevents inlining of the short Repo Man row in example 3.3.
Discussion
The only solution I can think of is to have a setting,
AlignPropertiesMaxLabelSize(or something), and only try to line up the properties if the name is less than or equal to that size.Instead of an absolute size, maybe the setting could look at the difference in size between the largest and smallest names, or between the largest and the average. I'm not sure that really helps much, though, and would probably confuse people.
One way or another, there probably needs to be a way to disable this feature. I assume someone will dislike it, somewhere.
Another question is where to put the colons: after the padding, next to the value (as in the examples above); or before the padding, next to the property name? (This is somewhat similar to the setting
TableCommaPlacementintroduced in 4.1 to control where to put commas relative to the padding.)What are your thoughts? Are there edge cases I haven't thought of? What settings should control it? What defaults?
Beta Was this translation helpful? Give feedback.
All reactions