{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import json\n", "\n", "from ezjson import prettyjson" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##prettyjson doc" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Pretty display json or dictionnary in collapsible format with indents\n", "\n", " Options are\n", " depth: Depth of the json tree structure displayed, the rest is collapsed. By default: 2.\n", " max_length: Maximum number of characters of a string displayed as preview, longer string appear collapsed. By default: 20.\n", " sort: Whether the json keys are sorted alphabetically. By default: True.\n", " max_height: Maxium height in pixels of containing div. By default: 600.\n", "\n", " Examples:\n", " 1/ Python dictionary\n", " dic = {'sape': {'value': 22}, 'jack': 4098, 'guido': 4127}\n", " prettyjson(dic, depth=1, max_length=10, sort=False)\n", "\n", " 2/ json string\n", " json_str = '{\"glossary\": {\"empty array\": [], \"empty object\": {}, \"string\": \"example glossary\", \"null field\": null, \"object\": {\"GlossList\": {\"GlossEntry\": {\"GlossDef\": {\"GlossSeeAlso\": [\"GML\", \"XML\"], \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\"}, \"GlossSee\": \"markup\", \"Acronym\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Abbrev\": \"ISO 8879:1986\", \"SortAs\": \"SGML\", \"ID\": \"SGML\"}}, \"title\": \"S\"}, \"number\": 2, \"undefined field\": \"undefined\", \"boolean\": false, \"array\": [3, 5]}}'\n", " prettyjson(json_str, depth=6, max_length=10, max_height=500)\n", "\n", " \n" ] } ], "source": [ "print prettyjson.__doc__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##from Python dictionnary" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " " ], "text/plain": [ "