Skip to content

Conversation

daxian-dbw
Copy link

This PR is for the discussion #1841

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

Today, the indent size for rendering a JsonText instance is hard coded to be 3 spaces. For a deep JSON object, it'd nice if I can set the indent size to be 2 to have more rendered within the same console space. So, I propose to make the indent size configurable for an JsonText instance.

The changes are simple:

  1. Update JsonBuilderContext
    • Add a read-only property int IndentWidth
    • Update the constructor take another parameter int indentWidth, and assign its value to the read-only property IndentWidth
    • Update the InsertIndentation method to have Indentation * IndentWidth instead.
  2. Add a new read-write property IndentWidth to JsonText to allow user set value
    • Use 3 as the default value so the default behavior is unchanged.
    • Pass it in when creating the JsonBuilderContext instance in the Build() method.

I think it may be reasonable to make sure the value assigned to IndentWidth is between 2 and 4 inclusively, to make user only choose from 2, 3, or 4 spaces.


Please upvote 👍 this pull request if you are interested in it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant