-
Notifications
You must be signed in to change notification settings - Fork 81
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 output format #305
Comments
(note conditional formatting is also requested in #296 - this is clearly a pain point) |
+1 I think it's a lot better to include a small dependency than to reinvent the wheel with formatting. My use case is using I made a python script using #!/usr/bin/env python3
import dbus
import json
player = dbus.SessionBus().get_object('org.mpris.MediaPlayer2.playerctld', '/org/mpris/MediaPlayer2')
metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties')
print(json.dumps(metadata)) |
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bringing back this idea from an old issue: #64
I still think there's some value to a JSON output format, even when there's
--format
now.For example, I wanted to have a conditional formatting:
If both the artist and title name is available, I want to display
{{ artist }} - {{ title }}
.If only the title name is available, I want to display
{{ title }}
.I tried playing around with the
default
function, but I don't think this is possible.This can be potentially implemented as part of the format string, but I think it's easier to just have the tool output JSON. This will be very powerful, because once you have a JSON string, you can do any logic you want with it. Also, JSON is available everywhere these days, even in the shell with tools like
jq
.The text was updated successfully, but these errors were encountered: