Skip to content
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

indent json with --pretty-json #32780

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

knighthat
Copy link

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

This switch --pretty-json prints result of --dump-json in a more human readable format. Applicable in storing video's information.

Reason: I am making a wrapper called youtube-dl-java. Loading 1 line of JSON with hundreds of thousands of characters takes a significantly long time due to how much memory is allocated for 1 single line.

This also makes it easier for users to inspect the return json since it's nicely indented.

@dirkf
Copy link
Contributor

dirkf commented May 9, 2024

Thanks for your proposal.

I don't think we should add a feature just to help your programming project. Instead, ask whether you are loading the JSON into your Java program efficiently, or why Python can handle files of this sort (eg, --load-info-json) without complaint. There seem to be quite a few libraries dedicated to doing this for Java.

Also, there are many external tools available for JS[ON] parsing and beautification, such as jq.

@knighthat
Copy link
Author

The main purpose of this feature is to let user save outputs to physical file. There are tools out there and I'm using it daily too but why do I have to install or write a script to parse it when python can just do the same?

Btw, copying 1 line of string with hundreds of thousands of characters is a real pain.

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.

None yet

2 participants