Warning, /education/cantor/src/test/data/TestNotebookWithModJson.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 "text/plain": [ 0056 "<__main__.RenderJSON at 0x7fa1599c6828>" 0057 ] 0058 }, 0059 "metadata": {}, 0060 "output_type": "display_data" 0061 } 0062 ], 0063 "source": [ 0064 "RenderJSON([\n", 0065 " {\n", 0066 " \"a\": 1\n", 0067 " }, \n", 0068 " {\n", 0069 " \"b\": 2,\n", 0070 " \"in1\": {\n", 0071 " \"key\": \"value\"\n", 0072 " }\n", 0073 " }\n", 0074 "])" 0075 ] 0076 }, 0077 { 0078 "cell_type": "code", 0079 "execution_count": null, 0080 "metadata": {}, 0081 "outputs": [], 0082 "source": [] 0083 } 0084 ], 0085 "metadata": { 0086 "kernelspec": { 0087 "display_name": "Python 3", 0088 "language": "python", 0089 "name": "python3" 0090 }, 0091 "language_info": { 0092 "codemirror_mode": { 0093 "name": "ipython", 0094 "version": 3 0095 }, 0096 "file_extension": ".py", 0097 "mimetype": "text/x-python", 0098 "name": "python", 0099 "nbconvert_exporter": "python", 0100 "pygments_lexer": "ipython3", 0101 "version": "3.6.8" 0102 } 0103 }, 0104 "nbformat": 4, 0105 "nbformat_minor": 2 0106 }