Last active
November 17, 2021 14:44
-
-
Save shanehh/b1b382769b42952e4b9de6a161e7745b to your computer and use it in GitHub Desktop.
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
import pyperclip | |
import json | |
def object2json_and_copy_it_to_clipboard(obj): | |
""" | |
convert any object jsonable(if need), and dumps it | |
copy to clipboard | |
""" | |
if hasattr(obj, "__dict__"): | |
obj = obj.__dict__ | |
result = json.dumps(obj, ensure_ascii=False, indent=2) | |
pyperclip.copy(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment