-
Notifications
You must be signed in to change notification settings - Fork 27
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
json pretty print #84
Conversation
please post an example of the difference so I might merge it right away. |
original {"media": [{"media_id": "SFZOcLZamWeKnsnJrfqwfcxr", "media_type": "image/jpeg", "media_length": 344120, "upload_name": "LcV3Ep_YqlJss9A_G8i6", "created_ts": "2022-06-10 16:47:37", "last_access_ts": "2022-11-07 15:01:55", "quarantined_by": null, "safe_from_quarantine": false}, {"media_id": "OgKciuaCYxnBMiiHXXcWqzKP", "media_type": "image/png", "media_length": 786276, "upload_name": "99HFJP4R6Kjvbp9NR0_y", "created_ts": "2022-01-18 17:26:20", "last_access_ts": "2022-04-08 11:04:19", "quarantined_by": null, "safe_from_quarantine": false}], "total": 2} updated {
"media": [
{
"media_id": "SFZOcLZamWeKnsnJrfqwfcxr",
"media_type": "image/jpeg",
"media_length": 344120,
"upload_name": "LcV3Ep_YqlJss9A_G8i6",
"created_ts": "2022-06-10 16:47:37",
"last_access_ts": "2022-11-07 15:01:55",
"quarantined_by": null,
"safe_from_quarantine": false
},
{
"media_id": "OgKciuaCYxnBMiiHXXcWqzKP",
"media_type": "image/png",
"media_length": 786276,
"upload_name": "99HFJP4R6Kjvbp9NR0_y",
"created_ts": "2022-01-18 17:26:20",
"last_access_ts": "2022-04-08 11:04:19",
"quarantined_by": null,
"safe_from_quarantine": false
}
],
"total": 2
} |
Oh, alright that's looking nice but actually we have -o pprint for human readable output. You tried that? Main question being with your change to json output: Will this still be batch-processable? I.e piping to jq for example? Thats the most important usecase for json out. |
Yes, it's readable, but it's not json.
Yes, jq works fine, I've tested it.
|
I wonder if -o pprint should implement the pretty-printed-json you suggest here and json should stay json in a single string (as-is). What do you think? I am not sure if -o pprint as it's currently implemented has any other purpose to users than just to look nice.... On the other hand, changing it might break existing behaviour in case people have shell scripts that depend on how exactly -o pprint currently looks like for further processing. Not sure how to proceed. What's your opinion? |
I see two options how to proceed in case you want to keep the compatibility and current behaviour.
However I don't see any problem with multiline json string, yaml is also multiline. |
Hi and sorry for the delay. Do you mind joining #synadm:peek-a-boo.at, we were discussing on what's the best way to proceed here. Some valuable opinions and suggestions there. If that's not possible for you at this time, no worries, I'll get back here with a final word on what we decided is best for the project / for users. Thanks for your patience! |
Hi @waclaw66, again: Sorry for the delay and blocking your efforts. I think we have a decision. We'd like to extend this PR to result in the following: Original json mode changes to the pretty version
and creating one for the oneline/minified version:
After your changes are through I will take the task of improving |
Also just to be complete here, I'd like to answer to your suggestions:
Good idea and we discussed it in #synadm. In the end renaming the original minified json to something and making the prettified version the new default seems to be the better idea on the long run.
In don't think that's a possible solution since --pretty does not make sense with formats that are already human readable, thus this could be more confusing than helpful. For example:
Yes you are right, for most cases and users this seems to be the best solution. For maximum flexibility or possibly performace-critical use-cases, keeping the minified json an option could be helpful. |
Hi @waclaw66, just want to check in and ask if you still have these requested changes on your radar (#84 (comment)) and whether you plan to submit them? No hurry, since it's not a critical bug fix but a new feature: If you manage to submit during some time in January it's perfectly fine. If you don't find the time until then please give us a heads up. Cheers! |
Some code pointers that might help:
Global option |
Hi @waclaw66, friendly reminder :-) Will you have time for finishing this PR or would you rather prefer we finish it ourselves. Any answer is ok and just better than no answer at all. Hope you understand! :-) Thanks and all the best! |
Hi @JOJ0, I'm sorry for the late response, please finish it on your own. Currently I'm quite busy. Thanks for understanding. |
I think I'll reconsider here just a little. |
I will finalize this feature in master....or rather in our dev branch....soon... |
- Keep -o json as the new default as the PR suggests. - Add a new mode -o jsonmini that still outputs oneline-json as the original json output mode did. - Improve handling of help text. We didn't have any description of the modes with the global --output flag. It was hidden with the config -o subcommand. It's shown in both places now.
Finalize PR #84 and improve --output helptext
No description provided.