Skip to content

jq: add option to pretty print JSON output#116

Merged
mislav merged 2 commits intocli:trunkfrom
mjpieters:jq_pretty_print
Apr 5, 2023
Merged

jq: add option to pretty print JSON output#116
mislav merged 2 commits intocli:trunkfrom
mjpieters:jq_pretty_print

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.

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
@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.

3 participants