Skip to content

Allow setting indent width or character in json.tool #426

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

Closed
wants to merge 1 commit into from
Closed

Allow setting indent width or character in json.tool #426

wants to merge 1 commit into from

Conversation

int-ua
Copy link

@int-ua int-ua commented Mar 3, 2017

Allows having shorter or wider indentation or using tabs for it, like this:

$ python3 -m json.tool input.json --indent=$'\t'

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:

  1. If you don't have an account on b.p.o, please create one
  2. Make sure your GitHub username is listed in "Your Details" at b.p.o
  3. If you have not already done so, please sign the PSF contributor agreement. The "bugs.python.org username " requested by the form is the "Login name" field under "Your Details".
  4. If you just signed the CLA, please wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  5. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

@mention-bot
Copy link

@int-ua, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @tiran, @berkerpeksag, @ezio-melotti and @serhiy-storchaka to be potential reviewers.

@serhiy-storchaka
Copy link
Member

This is a duplicate of bpo-29636 and #345.

@int-ua
Copy link
Author

int-ua commented Mar 3, 2017

Sorry, looks like I've made a typo when searching before posting.

@int-ua
Copy link
Author

int-ua commented Mar 16, 2017

Wait, #345 doesn't allow tabs.

@dhimmel
Copy link
Contributor

dhimmel commented Mar 16, 2017

@int-ua see conversation here. Initially, I had implemented a solution that supported indent='\t', indent=None, and indent corresponding to any int or string. However, the reviewers didn't like the special casing, which I agree is undesirable.

@serhiy-storchaka mentioned:

You can use external commands like unexpand for converting spaces to tabs.

It doesn't look like your PR currently supports setting an int indent. I guess you could always pass --indent=" " for two spaces. Let's direct further design discussion to bpo-29636.

@int-ua
Copy link
Author

int-ua commented Mar 23, 2017

It did allow integers, see line 38. Also, to prevent misunderstanding: I don't care at all whose commit is going to be merged, I really appreciate all Python authors' work and I just want tabs, a character created specifically to set indent level. Now, that's all, moving to BPO.

options = parser.parse_args()

infile = options.infile or sys.stdin
outfile = options.outfile or sys.stdout
sort_keys = options.sort_keys
try:
indent = int(options.indent)
Copy link
Contributor

@dhimmel dhimmel Mar 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad... clearly supports int!

jaraco pushed a commit that referenced this pull request Dec 2, 2022
Bumps [gidgethub](https://github.com/brettcannon/gidgethub) from 4.2.0 to 5.0.0.
- [Release notes](https://github.com/brettcannon/gidgethub/releases)
- [Changelog](https://github.com/brettcannon/gidgethub/blob/master/docs/changelog.rst)
- [Commits](gidgethub/gidgethub@v4.2.0...5.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
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.

5 participants