From 310e5481079acbb92de047ce822acf7fae3407d1 Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:13:16 +0530 Subject: [PATCH 1/7] chore: convert README from rst to md format --- README.md | 216 +++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 241 ----------------------------------------------------- 2 files changed, 216 insertions(+), 241 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..2cacb50 --- /dev/null +++ b/README.md @@ -0,0 +1,216 @@ +# json2html + +Python module to convert `JSON` into a human readable `HTML Table` representation. + +![Latest Version](https://img.shields.io/pypi/v/json2html.svg) ![Downloads](https://img.shields.io/pypi/dm/json2html.svg) [![CI](https://github.com/softvar/json2html/workflows/CI/badge.svg?branch=master)](https://github.com/softvar/json2html/actions?query=workflow%3ACI) + +## Features + +- User friendly tabular format, easy to read and share. +- If the value of the key is an array of objects and all the keys are the same (value of the key is a dict of a list), the module will club by default. E.g.: + + ```bash + input = { + "sampleData": [{ + "a":1, "b":2, "c":3 + }, { + "a":5, "b":6, "c":7 + }] + } + ``` + + This will create only one row combining the results. This feature can be turned off by explicitly passing an argument `clubbing = False`. + +- The generated table can have some `attributes` explicitly. E.g. giving an `id`, `class`, or any `data-*` attribute. +- Python 3 compatible. + +## Live Demo + +[Click here](http://json2html.varunmalhotra.xyz/) for the online demo. + +## List of Valid Arguments + +`json2html.convert` - The module's `convert` method accepts the following arguments: + +| Argument | Description | +|---------------------|-------------| +| `json` | A valid JSON; This can either be a string in valid JSON format or a Python object that is either dict-like or list-like at the top level. | +| `table_attributes` | E.g. pass `id="info-table"` or `class="bootstrap-class"`/`data-*` to apply these attributes to the generated table. | +| `clubbing` | Turn on [default]/off clubbing of list with the same keys of a dict / Array of objects with the same key. | +| `encode` | Turn on/off [default] encoding of result to escaped HTML, compatible with any browser. | +| `escape` | Turn on [default]/off escaping of HTML tags in text nodes (prevents XSS attacks in case you pass untrusted data to json2html). | + +## Installation + +```bash +pip install json2html +``` + +Or, Download [here](https://github.com/softvar/json2html/releases) and run `python setup.py install` after changing directory to `/json2html` + +## Example Usage + +**Example 1:** Basic usage + +```python +from json2html import * +input = { + "name": "json2html", + "description": "Converts JSON to HTML tabular representation" +} +json2html.convert(json = input) +``` + +Output: + +```html +
namejson2html
descriptionconverts JSON to HTML tabular representation
+``` + +| name | description | +|-------------|--------------------------------------------------| +| json2html | Converts JSON to HTML tabular representation | + + +**Example 2:** Setting custom attributes to table + +```python +from json2html import * +input = { + "name": "json2html", + "description": "Converts JSON to HTML tabular representation" +} +json2html.convert(json = input, table_attributes="id=\"info-table\" class=\"table table-bordered table-hover\"") +``` + +Output: + +```html +
namejson2html
descriptionConverts JSON to HTML tabular representation
+``` + +**Example 3:** Clubbing same keys of: Array of Objects + +```python +from json2html import * +input = { + "sample": [{ + "a":1, "b":2, "c":3 + }, { + "a":5, "b":6, "c":7 + }] +} +json2html.convert(json = input) +``` + +Output: + +```html +
sample
bca
231
675
+``` + +| a | c | b | +|-----|-----|-----| +| 1 | 3 | 2 | +| 5 | 7 | 6 | + + +**Example 4:** Each row for different key(s) of: Array of Objects + +```python +from json2html import * +input = { + "sample": [{ + "a":1, "b":2, "c":3 + }, { + "1a1":5, "1b1":6, "c":7 + }] +} +json2html.convert(json = input) +``` + +Output: + +```html +
sample
  • a1
    c3
    b2
  • 1b16
    c7
    1a15
+``` + +**Example 5:** [Source: `json.org/example `_] + +```python +from json2html import * + +input = { + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} + +json2html.convert(json = input) +``` + +Output: + +```html +
glossary
GlossDiv
GlossList
GlossEntry
GlossDef
GlossSeeAlso
  • GML
  • XML
paraA meta-markup language, used to create markup languages such as DocBook.
GlossSeemarkup
AcronymSGML
GlossTermStandard Generalized Markup Language
AbbrevISO 8879:1986
SortAsSGML
IDSGML
titleS
titleexample glossary
+``` + +## Tests + +```bash +cd test/ +python run_tests.py +``` + +Tested on Python 2.7 and 3.5+. + +## Contributors + +1. Michel Mueller: [@muellermichel](https://github.com/muellermichel) + + * Added support for clubbing Array of Objects with same keys, more readable format. + * Added support for adding custom `table_attributes`. + * Convert now accepts unicode and bytestrings for the keyword argument "json". + * Output now should always appear in the same order as input. + * Now supports JSON Lists (at top level), including clubbing. + * Now supports empty inputs and positional arguments for convert. + * Python 3 support ; Added integration tests for Python 2.6, 3.4 and 3.5 such that support doesn't break. + * Can now also do the proper encoding for you (disabled by default to not break backwards compatibility). + * Can now handle non-JSON objects on a best-effort principle. + * Now by default escapes html in text nodes to prevent XSS attacks. + +2. Daniel Lekic: [@lekic](https://github.com/lekic) + * Fixed issue with one-item lists not rendering correctly. + * General code cleanup, fixed all naming conventions and coding standards to adhere to PEP8 conventions. + +3. Kyle Smith: [@smithk86](https://github.com/smithk86) + * Added thead and tbody tags to group header and content rows when creating a table from an array of objects. + +## Copyright and License + +The `MIT license `_ + +Copyright (c) 2013-2024 Varun Malhotra + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rst b/README.rst deleted file mode 100644 index aa7bb04..0000000 --- a/README.rst +++ /dev/null @@ -1,241 +0,0 @@ -json2html -========= - -Python module to convert ``JSON`` into a human readable ``HTML Table`` representation. - -|Latest Version| |Downloads| |Build| - -.. |Build| image:: https://api.travis-ci.org/softvar/json2html.png - -.. |Latest Version| image:: https://img.shields.io/pypi/v/json2html.svg - :target: https://pypi.python.org/pypi/json2html - -.. |Downloads| image:: https://img.shields.io/pypi/dm/json2html.svg - :target: https://pypi.python.org/pypi/json2html - -Features --------- - -* User friendly tablular fomat, easy to read and share. -* If value of the key is array of objects and all the keys are same(value of the key is a dict of list), the module will club by default. Eg. - -.. code-block:: bash - - input = { - "sampleData": [{ - "a":1, "b":2, "c":3 - }, { - "a":5, "b":6, "c":7 - }] - } - - will create only one row combining the results. This feature can be turned off by explicitly passing an argument ``clubbing = False``. - -* Generated table can be provided some ``attributes`` explicitly. Eg. giving an ``id``, ``class`` or any ``data-*`` attribute. -* Python 3 compatible - -Live Demo ----------- - -`Click here `_ for the online demo. - -List of valid arguments ------------------------ - -``json2html.convert`` - The module's ``convert`` method accepts the following arguments: - -===================== ================ -Argument Description ---------------------- ---------------- -`json` a valid JSON; This can either be a string in valid JSON format or a python object that is either dict-like or list-like at the top level. ---------------------- ---------------- -`table_attributes` e.g. pass `id="info-table"` or `class="bootstrap-class"`/`data-*` to apply these attributes to the generated table ---------------------- ---------------- -`clubbing` turn on[default]/off clubbing of list with same keys of a dict / Array of objects with same key ---------------------- ---------------- -`encode` turn on/off[default] encoding of result to escaped html, compatible with any browser ---------------------- ---------------- -`escape` turn on[default]/off escaping of html tags in text nodes (prevents XSS attacks in case you pass untrusted data to json2html) -===================== ================ - -Installation ------------- - -.. code-block:: bash - - $ pip install json2html - -Or, Download [here](https://github.com/softvar/json2html/releases) and run `python setup.py install` after changing directory to `/json2html` - -Example Usage -------------- - -**Example 1:** Basic usage - -.. code-block:: python - - from json2html import * - input = { - "name": "json2html", - "description": "Converts JSON to HTML tabular representation" - } - json2html.convert(json = input) - -Output: - -.. code-block:: bash - -
namejson2html
descriptionconverts JSON to HTML tabular representation
- -============ ======================================================== -name json2html ------------- -------------------------------------------------------- -description Converts JSON to HTML tabular representation -============ ======================================================== - -**Example 2:** Setting custom attributes to table - -.. code-block:: python - - from json2html import * - input = { - "name": "json2html", - "description": "Converts JSON to HTML tabular representation" - } - json2html.convert(json = input, table_attributes="id=\"info-table\" class=\"table table-bordered table-hover\"") - -Output: - -.. code-block:: bash - -
namejson2html
descriptionConverts JSON to HTML tabular representation
- -**Example 3:** Clubbing same keys of: Array of Objects - -.. code-block:: python - - from json2html import * - input = { - "sample": [{ - "a":1, "b":2, "c":3 - }, { - "a":5, "b":6, "c":7 - }] - } - json2html.convert(json = input) - -Output: - -.. code-block:: bash - -
sample
bca
231
675
- -======== ======= ======= - a c b --------- ------- ------- - 1 3 2 --------- ------- ------- - 5 7 6 -======== ======= ======= - -**Example 4:** Each row for different key(s) of: Array of Objects - -.. code-block:: python - - from json2html import * - input = { - "sample": [{ - "a":1, "b":2, "c":3 - }, { - "1a1":5, "1b1":6, "c":7 - }] - } - json2html.convert(json = input) - -Output: - -.. code-block:: bash - -
sample
  • a1
    c3
    b2
  • 1b16
    c7
    1a15
- -**Example 5:** [Source: `json.org/example `_] - -.. code-block:: python - - from json2html import * - - input = { - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": ["GML", "XML"] - }, - "GlossSee": "markup" - } - } - } - } - } - - json2html.convert(json = input) - -Output: - -.. code-block:: bash - -
glossary
GlossDiv
GlossList
GlossEntry
GlossDef
GlossSeeAlso
  • GML
  • XML
paraA meta-markup language, used to create markup languages such as DocBook.
GlossSeemarkup
AcronymSGML
GlossTermStandard Generalized Markup Language
AbbrevISO 8879:1986
SortAsSGML
IDSGML
titleS
titleexample glossary
- -Tests ------- - -.. code-block:: bash - - cd test/ - python run_tests.py - -Tested with Python 2.7 and 3.5+. - -Contributors ------------- - -1. Michel Mueller: [@muellermichel](https://github.com/muellermichel) - * Added support for clubbing Array of Objects with same keys, more readable format. - * Added support for adding custom `table_attributes`. - * Convert now accepts unicode and bytestrings for the keyword argument "json". - * Output now should always appear in the same order as input. - * Now supports JSON Lists (at top level), including clubbing. - * Now supports empty inputs and positional arguments for convert. - * Python 3 support ; Added integration tests for Python 2.6, 3.4 and 3.5 such that support doesn't break. - * Can now also do the proper encoding for you (disabled by default to not break backwards compatibility). - * Can now handle non-JSON objects on a best-effort principle. - * Now by default escapes html in text nodes to prevent XSS attacks. - -2. Daniel Lekic: [@lekic](https://github.com/lekic) - * Fixed issue with one-item lists not rendering correctly. - * General code cleanup, fixed all naming conventions and coding standards to adhere to PEP8 conventions. - -3. Kyle Smith: [@smithk86](https://github.com/smithk86) - * Added thead and tbody tags to group header and content rows when creating a table from an array of objects. - -Copyright and License ---------------------- - - The `MIT license `_ - - Copyright (c) 2013-2021 Varun Malhotra - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 311268f3b4c4fbd23c61223efb7fe5b2f34f26e3 Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:13:46 +0530 Subject: [PATCH 2/7] chore: use github-action instead of travis for running tests --- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ .travis.yml | 10 ---------- requirements-ci.txt | 1 + 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 requirements-ci.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f4c45cb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + if: "!contains(toJSON(github.event.commits.*.message), '[skip-ci]')" + name: Test on python ${{ matrix.python-version }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-20.04 + python-version: [ 2.7, 3.5, 3.6.7, 3.6.10, 3.6.14, 3.7.5, 3.7.11, 3.8.0, 3.8.5, 3.9.0, 3.9.6, 3.9.18, 3.10.13, 3.11.6] + + steps: + - uses: actions/checkout@v3 + - name: Use Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install packages + run: | + python -m pip install --upgrade pip + if [ -f requirements-ci.txt ]; then pip install -r requirements-ci.txt; fi + + - name: Run tests + run: coverage run --source=json2html setup.py test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 00cb1c7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: python -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "3.8-dev" - -# command to run tests -script: cd test/ && python run_tests.py diff --git a/requirements-ci.txt b/requirements-ci.txt new file mode 100644 index 0000000..68cdb9d --- /dev/null +++ b/requirements-ci.txt @@ -0,0 +1 @@ + coverage==4.5.4 From 7c95425def99f2e449f04fd30641afa19c4826fe Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:14:08 +0530 Subject: [PATCH 3/7] chore: update year in license and files --- LICENSE | 2 +- MANIFEST.in | 2 +- json2html/__init__.py | 2 +- json2html/jsonconv.py | 2 +- setup.cfg | 4 ++-- setup.py | 3 +-- test/__init__.py | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 4134a77..7cbe35c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013-2021 Varun Malhotra +Copyright (c) 2013-2024 Varun Malhotra Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MANIFEST.in b/MANIFEST.in index 926cc7b..3e677d0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -include README.rst +include README.md include LICENSE.txt diff --git a/json2html/__init__.py b/json2html/__init__.py index 645d17e..fc739c7 100644 --- a/json2html/__init__.py +++ b/json2html/__init__.py @@ -1,6 +1,6 @@ ''' python wrapper for JSON to HTML-Table convertor -(c) 2013-2021 Varun Malhotra. MIT License +(c) 2013-2024 Varun Malhotra. MIT License ''' from .jsonconv import * diff --git a/json2html/jsonconv.py b/json2html/jsonconv.py index 9ef8c73..dd27134 100644 --- a/json2html/jsonconv.py +++ b/json2html/jsonconv.py @@ -4,7 +4,7 @@ JSON 2 HTML Converter ===================== -(c) Varun Malhotra 2013-2021 +(c) Varun Malhotra 2013-2024 Source Code: https://github.com/softvar/json2html diff --git a/setup.cfg b/setup.cfg index de6a9db..fc4253a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [metadata] -description-file = README.rst -max-line-length = 120 \ No newline at end of file +description_file = README.md +max_line_length = 120 diff --git a/setup.py b/setup.py index 43b404a..d35259d 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,11 @@ from setuptools import setup - setup( name = 'json2html', packages = ['json2html'], version = '1.3.0', description = 'JSON to HTML Table Representation', - long_description=open('README.rst').read(), + long_description=open('README.md').read(), author = 'Varun Malhotra', author_email = 'varun2902@gmail.com', url = 'https://github.com/softvar/json2html', diff --git a/test/__init__.py b/test/__init__.py index 97e5354..1415654 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -2,7 +2,7 @@ Unit Test Cases for JSON2HTML Description - python wrapper for converting JSON to HTML Table format -(c) 2013 Varun Malhotra. MIT License +(c) 2013-2024 Varun Malhotra. MIT License ''' __author__ = 'Varun Malhotra' From 4ae6ac6d5639a5da768fc2428374520cb08b97f6 Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:18:28 +0530 Subject: [PATCH 4/7] chore: add requirements.txt file --- requirements.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 From f189bced49b0be2375cd94581742f2dfbd624c0d Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:20:50 +0530 Subject: [PATCH 5/7] chore: remove 2.7/3.5 as not supported in gtihub-action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4c45cb..0837b9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: matrix: os: - ubuntu-20.04 - python-version: [ 2.7, 3.5, 3.6.7, 3.6.10, 3.6.14, 3.7.5, 3.7.11, 3.8.0, 3.8.5, 3.9.0, 3.9.6, 3.9.18, 3.10.13, 3.11.6] + python-version: [ 3.6.7, 3.6.10, 3.6.14, 3.7.5, 3.7.11, 3.8.0, 3.8.5, 3.9.0, 3.9.6, 3.9.18, 3.10.13, 3.11.6] steps: - uses: actions/checkout@v3 From 247dca9b58ca4337e68908eaf28c264a15a93979 Mon Sep 17 00:00:00 2001 From: softvar Date: Fri, 28 Jun 2024 02:25:34 +0530 Subject: [PATCH 6/7] chore: codecov job and update readme with codecov badge --- .github/workflows/test.yml | 7 +++++++ README.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0837b9e..719e76d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,3 +33,10 @@ jobs: - name: Run tests run: coverage run --source=json2html setup.py test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + fail_ci_if_error: true diff --git a/README.md b/README.md index 2cacb50..9d418ec 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Python module to convert `JSON` into a human readable `HTML Table` representation. -![Latest Version](https://img.shields.io/pypi/v/json2html.svg) ![Downloads](https://img.shields.io/pypi/dm/json2html.svg) [![CI](https://github.com/softvar/json2html/workflows/CI/badge.svg?branch=master)](https://github.com/softvar/json2html/actions?query=workflow%3ACI) +![Latest Version](https://img.shields.io/pypi/v/json2html.svg) ![Downloads](https://img.shields.io/pypi/dm/json2html.svg) [![CI](https://github.com/softvar/json2html/workflows/CI/badge.svg?branch=master)](https://github.com/softvar/json2html/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/softvar/json2html/branch/master/graph/badge.svg?token=)](https://codecov.io/gh/softvar/json2html) ## Features From 0a223c7b3e5dce286811fb12bbab681e7212ebfe Mon Sep 17 00:00:00 2001 From: Adi Vaknin <6841988+DeepSpace2@users.noreply.github.com> Date: Fri, 28 Jun 2024 00:01:56 +0300 Subject: [PATCH 7/7] Made examples compatible with both Python 2 and 3 and fixed some typos (#41) Made examples compatible with both Python 2 and 3 and fixed some typos --- examples/basic.py | 4 ++-- examples/clubbing_keys_of_array_of_objects.py | 2 +- examples/deep_nesting.py | 2 +- examples/setting_custom_attrs.py | 4 ++-- test/basic.json | 2 +- test/basic.txt | 2 +- test/setting_custom_attrs.json | 2 +- test/setting_custom_attrs.txt | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/basic.py b/examples/basic.py index c33028f..b0d6889 100644 --- a/examples/basic.py +++ b/examples/basic.py @@ -7,8 +7,8 @@ _json = { "name": "Json2Html", - "desription": "converts json 2 html table format" + "description": "converts json 2 html table format" } output = json2html.convert(json = _json) -print output +print(output) diff --git a/examples/clubbing_keys_of_array_of_objects.py b/examples/clubbing_keys_of_array_of_objects.py index ca299a3..3877c73 100644 --- a/examples/clubbing_keys_of_array_of_objects.py +++ b/examples/clubbing_keys_of_array_of_objects.py @@ -13,4 +13,4 @@ } output = json2html.convert(json = _json) -print output +print(output) diff --git a/examples/deep_nesting.py b/examples/deep_nesting.py index f33b20e..30c5818 100644 --- a/examples/deep_nesting.py +++ b/examples/deep_nesting.py @@ -29,4 +29,4 @@ } output = json2html.convert(json = _json) -print output +print(output) diff --git a/examples/setting_custom_attrs.py b/examples/setting_custom_attrs.py index 937d562..f2ade5f 100644 --- a/examples/setting_custom_attrs.py +++ b/examples/setting_custom_attrs.py @@ -8,8 +8,8 @@ _json = { 'name': 'Json2Html', 'language':'python', - 'desription': 'converts json 2 html table format' + 'description': 'converts json 2 html table format' } output = json2html.convert(json = _json, table_attributes="class=\"table table-bordered table-hover\"") -print output +print(output) diff --git a/test/basic.json b/test/basic.json index aef2860..3139486 100644 --- a/test/basic.json +++ b/test/basic.json @@ -1,4 +1,4 @@ { "name": "Json2Html", - "desription": "converts json 2 html table format" + "description": "converts json 2 html table format" } diff --git a/test/basic.txt b/test/basic.txt index ae7d782..f0ccc8a 100644 --- a/test/basic.txt +++ b/test/basic.txt @@ -4,7 +4,7 @@ Json2Html - desription + description converts json 2 html table format \ No newline at end of file diff --git a/test/setting_custom_attrs.json b/test/setting_custom_attrs.json index 2545181..24de1d1 100644 --- a/test/setting_custom_attrs.json +++ b/test/setting_custom_attrs.json @@ -1,5 +1,5 @@ { "name": "Json2Html", "language":"python", - "desription": "converts json 2 html table format" + "description": "converts json 2 html table format" } diff --git a/test/setting_custom_attrs.txt b/test/setting_custom_attrs.txt index 8978536..7912ec0 100644 --- a/test/setting_custom_attrs.txt +++ b/test/setting_custom_attrs.txt @@ -8,7 +8,7 @@ python - desription + description converts json 2 html table format \ No newline at end of file