Last active
August 29, 2015 14:23
-
-
Save InFog/9465e2cf36c3765f4be7 to your computer and use it in GitHub Desktop.
Format JSON in your clipboarb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from tkinter import Tk | |
from json import dumps, loads | |
def show_json_from_clipboard(): | |
t = Tk() | |
t.withdraw() | |
try: | |
json = loads(t.clipboard_get()) | |
except: | |
print("There is no valid JSON in your clipboard") | |
return 1 | |
print(dumps(json, indent=4, sort_keys=True)) | |
return 0 | |
if __name__ == '__main__': | |
exit(show_json_from_clipboard()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment