Created
November 7, 2024 21:26
-
-
Save cu/570a8f7104645e4835755e3433c3d443 to your computer and use it in GitHub Desktop.
JSON Pretty Printer and Highlighter
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 json | |
import sys | |
from pygments import highlight | |
from pygments.lexers import JsonLexer | |
from pygments.formatters import TerminalFormatter | |
if __name__ == "__main__": | |
print( | |
highlight( | |
json.dumps(json.loads(sys.stdin.read()), indent=4), | |
JsonLexer(), | |
TerminalFormatter(), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment