Registry / data / json2table

json2table

JSON →
library1.1.5pypypi✓ verified 85d ago

A library to convert JSON or Python dicts into an HTML table. Current version 1.1.5. Low release cadence.

pip install json2table
INSTALL
IMPORT
SIG · JSON2TABLE
J
json2table
datapythonv1.1.5
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.006s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
from json2table import convert
import json2table
Import the function directly; the module itself is not callable.

Basic usage: convert a nested dict to an HTML table string.

from json2table import convert json_data = { "name": "Alice", "age": 30, "address": { "street": "123 Maple St", "city": "Springfield" } } table_attributes = {"style": "width:100%"} table = convert(json_data, table_attributes=table_attributes) print(table)
Debug
Known issues
breakingThe order of dictionary keys is not preserved. Python dicts preserve insertion order from 3.7+, but json2table may sort keys alphabetically.
fix
Use an OrderedDict if key order matters, or check the generated HTML order.
affects: all
gotchaNested JSON objects are expanded into sub-tables by default. This can produce deeply nested HTML if not controlled.
fix
Use the `max_level` parameter to limit depth or customize with `build_converter`.
affects: all
gotchaThe `table_attributes` parameter expects a dict, not a string. Common mistake is passing HTML attributes as a string like 'class="my-table"'.
fix
Pass a dict: {'class': 'my-table'}.
affects: all
Errors
Common errors & fixes
TypeError: 'module' object is not callable
Importing the whole module and trying to call it as a function, e.g. `json2table(data)`.
fix
Use `from json2table import convert` then call `convert(data)`.
AttributeError: module 'json2table' has no attribute 'convert'
Conflicting namespace or incorrect import path. Possibly having another module named json2table in the path.
fix
Check for local files named json2table.py and rename them. Use pip list to verify installed version.
TypeError: string indices must be integers
Passing a JSON string instead of a Python dict. The library expects a parsed dict.
fix
Parse JSON string first: `import json; data = json.loads(json_string); convert(data)`.
Upgrade
Version history
1.1.5latest on PyPI · released Oct 21, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
json2table — pip install json2table · libregistry