Skip to content

Instantly share code, notes, and snippets.

@Rhynorater
Created June 11, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rhynorater/0b04d6aa666fb66397801439ce64624f to your computer and use it in GitHub Desktop.
Save Rhynorater/0b04d6aa666fb66397801439ce64624f to your computer and use it in GitHub Desktop.
Format JSON Data in the Clipboard
#! /usr/bin/env python3
import pyperclip
import json
contents = pyperclip.paste().replace('[^\\]\\"', '\\\\"')
print(contents)
try:
c = json.loads(contents)
pyperclip.copy(json.dumps(c, indent=4))
except Exception as e:
a = open("/tmp/error.log", "w")
a.write("Exception: "+str(e))
a.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment