Skip to content

Instantly share code, notes, and snippets.

@ycaty
Created September 13, 2022 16:30
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 ycaty/26e4a4526b548d00ecb4ae1b1f8fd142 to your computer and use it in GitHub Desktop.
Save ycaty/26e4a4526b548d00ecb4ae1b1f8fd142 to your computer and use it in GitHub Desktop.
print colorful json
from pygments import highlight
from pygments.formatters.terminal import TerminalFormatter
from pygments.lexers.web import JsonLexer
dict = {'123':{'cats':6,'dogs':0}}
raw_json = json.dumps(dict , indent=4)
colorful_json = highlight(
raw_json,
lexer=JsonLexer(),
formatter=TerminalFormatter(),
)
print(colorful_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment