.. _nbjsonrst: ======================= Show JSON in a notebook ======================= .. only:: html **Links:** :download:`notebook `, :downloadlink:`html `, :download:`PDF `, :download:`python `, :downloadlink:`slides `, :githublink:`GitHub|_doc/notebooks/nb_json.ipynb|*` Displays `JSON `__ in a notebook. Inspired from `Pretty JSON Formatting in IPython Notebook `__. We use the trick described just above. The only addition is the use of an external library `renderjson `__. The code is here : `json_helper.py `__. .. code:: ipython3 from jyquickhelper import JSONJS JSONJS(dict(name="xavier", city="Paris"), only_html=True, show_to_level=3) .. raw:: html
.. code:: ipython3 import requests data_json = requests.get("http://api.worldbank.org/countries?incomeLevel=LMC&format=json").json() JSONJS(data_json) .. raw:: html