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

jq: add option to pretty print JSON output #116

Merged
merged 2 commits into from Apr 5, 2023

Conversation

mjpieters
Copy link
Contributor

Adds a new function EvaluateFormatted to maintain backward compatibility.
Indenting output by 2 spaces matches jq output.

Needed for cli/cli#3994

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good, but I would propose one addition that would make this more flexible to use.

pkg/jq/jq.go Outdated Show resolved Hide resolved
pkg/jq/jq.go Outdated Show resolved Hide resolved
Adds a new function `EvaluateFormatted` to maintain backward compatibility;
colorizing is handled by pkg/jsonpretty in this repository.
@mjpieters
Copy link
Contributor Author

@mislav: thanks for the update there, it shows how green I am around my GoLang ears here.

@mislav
Copy link
Contributor

mislav commented Apr 5, 2023

No worries and you're welcome. Your solution wasn't perfectly fine. My approach ins't necessarily less code but I think it might be easier to read and comprehend.

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

🚀

@mislav mislav merged commit fadea2b into cli:trunk Apr 5, 2023
6 checks passed
@mjpieters
Copy link
Contributor Author

No worries and you're welcome. Your solution wasn't perfectly fine. My approach ins't necessarily less code but I think it might be easier to read and comprehend.

Well, I care a lot about readability, and the whole encoder setup was not giving me the 'this code just fits' feeling yet. I like the approach you took because that is a lot more readable. I've made note, so thanks again!

@mjpieters mjpieters deleted the jq_pretty_print branch April 5, 2023 17:01
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

3 participants