Warning, /education/cantor/src/test/data/TestNotebookWithJson.ipynb is written in an unsupported language. File is not indexed.

0001 {
0002  "cells": [
0003   {
0004    "cell_type": "code",
0005    "execution_count": 6,
0006    "metadata": {},
0007    "outputs": [],
0008    "source": [
0009     "import json\n",
0010     "import uuid\n",
0011     "from IPython.display import display_javascript, display_html, display\n",
0012     "\n",
0013     "class RenderJSON(object):\n",
0014     "    def __init__(self, json_data):\n",
0015     "        if isinstance(json_data, dict) or isinstance(json_data, list):\n",
0016     "            self.json_str = json.dumps(json_data)\n",
0017     "        else:\n",
0018     "            self.json_str = json_data\n",
0019     "        self.uuid = str(uuid.uuid4())\n",
0020     "\n",
0021     "    def _ipython_display_(self):\n",
0022     "        display_html('<div id=\"{}\" style=\"height: 600px; width:100%;font: 12px/18px monospace !important;\"></div>'.format(self.uuid), raw=True)\n",
0023     "        display_javascript(\"\"\"\n",
0024     "        require([\"https://rawgit.com/caldwell/renderjson/master/renderjson.js\"], function() {\n",
0025     "            renderjson.set_show_to_level(2);\n",
0026     "            document.getElementById('%s').appendChild(renderjson(%s))\n",
0027     "        });\n",
0028     "      \"\"\" % (self.uuid, self.json_str), raw=True)"
0029    ]
0030   },
0031   {
0032    "cell_type": "code",
0033    "execution_count": 7,
0034    "metadata": {},
0035    "outputs": [
0036     {
0037      "data": {
0038       "text/html": [
0039        "<div id=\"bb6d9031-c990-4aee-849e-6d697430777c\" style=\"height: 600px; width:100%;font: 12px/18px monospace !important;\"></div>"
0040       ]
0041      },
0042      "metadata": {},
0043      "output_type": "display_data"
0044     },
0045     {
0046      "data": {
0047       "application/javascript": [
0048        "\n",
0049        "        require([\"https://rawgit.com/caldwell/renderjson/master/renderjson.js\"], function() {\n",
0050        "            renderjson.set_show_to_level(2);\n",
0051        "            document.getElementById('bb6d9031-c990-4aee-849e-6d697430777c').appendChild(renderjson([{\"a\": 1}, {\"b\": 2, \"in1\": {\"key\": \"value\"}}]))\n",
0052        "        });\n",
0053        "      "
0054       ]
0055      },
0056      "metadata": {},
0057      "output_type": "display_data"
0058     }
0059    ],
0060    "source": [
0061     "RenderJSON([\n",
0062     "    {\n",
0063     "        \"a\": 1\n",
0064     "    }, \n",
0065     "    {\n",
0066     "        \"b\": 2,\n",
0067     "        \"in1\": {\n",
0068     "            \"key\": \"value\"\n",
0069     "        }\n",
0070     "    }\n",
0071     "])"
0072    ]
0073   },
0074   {
0075    "cell_type": "code",
0076    "execution_count": null,
0077    "metadata": {},
0078    "outputs": [],
0079    "source": []
0080   }
0081  ],
0082  "metadata": {
0083   "kernelspec": {
0084    "display_name": "Python 3",
0085    "language": "python",
0086    "name": "python3"
0087   },
0088   "language_info": {
0089    "codemirror_mode": {
0090     "name": "ipython",
0091     "version": 3
0092    },
0093    "file_extension": ".py",
0094    "mimetype": "text/x-python",
0095    "name": "python",
0096    "nbconvert_exporter": "python",
0097    "pygments_lexer": "ipython3",
0098    "version": "3.6.8"
0099   }
0100  },
0101  "nbformat": 4,
0102  "nbformat_minor": 2
0103 }