Jupyter Notebook (and Jupyter Lab) comes with a very convenient and interactive JSON formatter. It's very useful for letting a user look through a very deep dictionary without flooding the output cell with a huge amount of information. Normally, if we have a dictionary called my_dict
, you can print its contents neatly to the output cell by:
from IPython.display import display, JSON
display(JSON(my_dict))
Which will give you something that looks like this:
The user can then interact with it to open/close different portions.
The problem is that if you take this approach, it doesn't seem to render properly on GitHub's web browser. In its place, you'll get:
<IPython.core.display.JSON object>
Any way I could have a nice JSON viewer like this that works on both a local JupyterLab instance, and on GitHub's website? Or am I forced to flood the output cell with hundreds of lines of JSON?
question from:
https://stackoverflow.com/questions/65946583/json-styling-in-jupyter-lab-and-github 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…