json2htmls
json2htmls is a package that converts json (dict) to html tables.
Installation
Use the package manager pip to install json2htmls.
pip install json2htmls
Available methods
json_to_html - converts json (dict) to html
normalize - normalizes json (dict) , converts values to strings
builder - main method that generates tables
json_arrays_to_dictionary - converts array of objects to objects , with suffixes
json_arrays_destroy - removes arrays from source
Usage
Example
from json2htmls import json_to_html
import json
with open('tests/sample.json') as json_file: # warning currently keys with values are not supported , e.g. "key": ["1", "2"]
data = json.load(json_file)
source , html = json_to_html(data) # source is the dictionary , html is the html itself
Result , use htmlviewer to see the result
<!DOCTYPE html>
<html>
<head>
<title>Report</title>
<style>table { page-break-inside:auto } tr { page-break-inside:avoid; page-break-after:auto } thead { display:table-header-group } tfoot { display:table-footer-group } .pointer { display: block; clear: both; page-break-after: always; } .clearfix { overflow: auto; clear: both } .clearfix::after { content: ""; clear: both; display: table; } body { margin: 0 7rem; } table { width: 100%; font-size: 0.8rem; } th,td { border: 0.11rem solid black; } table, th,td { border-collapse: collapse; padding: 0.25rem 1rem; text-align: left; margin: 0; } tr:nth-child(even) { background-color: #cccccc61; } </style>
</head>
<body>
<table class="clearfix" id="table_id">
<tbody>
<div class="pointer"></div>
<h3>General</h3>
<tr>
<th>Id</th>
<td>0001</td>
</tr>
<tr>
<th>Type</th>
<td>donut</td>
</tr>
<tr>
<th>Name</th>
<td>Cake</td>
</tr>
<tr>
<th>Ppu</th>
<td>0.55</td>
</tr>
<tr></tr>
</tbody>
</table>
<table class="clearfix" id="table_batter" style="page-break-inside: avoid; margin-top: 2rem;">
<tbody>
<tr id="row_heading_batter_heading">
<td colspan="2">
<h3 class="clearfix">Batter - 4</h3>
</td>
</tr>
<tr id="row_heading_batter_0">
<th>Id</th>
<th>Type</th>
</tr>
<tr id="row_batter_0">
<td>1001</td>
<td>Regular</td>
</tr>
<tr id="row_batter_1">
<td>1002</td>
<td>Chocolate</td>
</tr>
<tr id="row_batter_2">
<td>1003</td>
<td>Blueberry</td>
</tr>
<tr id="row_batter_3">
<td>1004</td>
<td>Devil's Food</td>
</tr>
</tbody>
</table>
<h3>Batters</h3>
<table class="clearfix" id="table_batters">
<tbody></tbody>
</table>
<table class="clearfix" id="table_topping" style="page-break-inside: avoid; margin-top: 2rem;">
<tbody>
<tr id="row_heading_topping_heading">
<td colspan="2">
<h3 class="clearfix">Topping - 7</h3>
</td>
</tr>
<tr id="row_heading_topping_0">
<th>Id</th>
<th>Type</th>
</tr>
<tr id="row_topping_0">
<td>5001</td>
<td>None</td>
</tr>
<tr id="row_topping_1">
<td>5002</td>
<td>Glazed</td>
</tr>
<tr id="row_topping_2">
<td>5005</td>
<td>Sugar</td>
</tr>
<tr id="row_topping_3">
<td>5007</td>
<td>Powdered Sugar</td>
</tr>
<tr id="row_topping_4">
<td>5006</td>
<td>Chocolate with Sprinkles</td>
</tr>
<tr id="row_topping_5">
<td>5003</td>
<td>Chocolate</td>
</tr>
<tr id="row_topping_6">
<td>5004</td>
<td>Maple</td>
</tr>
</tbody>
</table>
</body>
</html>
Contributing
Pull requests are welcome. Open issues addressing pull requests.
License
Metadata
Release files for json2htmls 0.0.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json2htmls-0.0.21.tar.gz | 6.5 kB | Without provenance | Details for json2htmls-0.0.21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json2htmls-0.0.21-py3-none-any.whl | Python 3 | none | any | Details for json2htmls-0.0.21-py3-none-any.whl |
Total release size: 9.9 kB
Release files / json2htmls-0.0.21.tar.gz
| Download URL | json2htmls-0.0.21.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9929ac24e0ab7d6cb97b15325996f0c38438d99f7718148600e03e0532fe0d11
|
|
BLAKE2b-256 checksum How to use checksums |
f01bc602118df8b37e382b253f9f12c5e55c3b6bbc3696894d585623df60136c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
|
Release files / json2htmls-0.0.21-py3-none-any.whl
| Download URL | json2htmls-0.0.21-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf0fc735617227865a836694f0b2a465d104b22849329a5a78ef7d63ffbf9695
|
|
BLAKE2b-256 checksum How to use checksums |
622ebfd780aee7011d298286212c36e192c91b7e1f8d728f27e8a86a006ee877
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
|
Security for json2htmls 0.0.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.