Makes any JSON compatible with D3's hierarchy or tree chart formats (see https://d3js.org)
Project description
json4tree
Makes any JSON compatible with D3's hierarchy or tree chart formats.
Installation
Since this tool is exclusively Python3
, you'll need pip3
to install:
pip3 install json4tree
You can also download and install the package directly from PyPi.
Usage
If your Python3
library is included in your path, try running json4tree
directly from the command line:
Note: The long name is a workaround until a bug with the __main__
script is fixed
python3 json4tree/__init__.py input.json output.json
Otherwise, you can import it as a module in your Python3
script:
# import the necessary modules
import json
import json4tree from json4tree
# import your JSON data
infile = open("input.json", "r")
json_file = json.load(infile)
infile.close()
# create a new handler
handler = json4tree(json_file)
# You can either print your results...
handler.results
# Or you can save your results
outfile = open("output.json", "w")
outfile.write(handler.results)
outfile.close()
Examples
Here is an example input file from Merriam-Webster's Dictionary API and the resulting output file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for json4tree-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a9f601fbf2c795a12664f6ccafb581870abe4efa35a3d4612093f4c2fd044c9 |
|
MD5 | c050cbc6318f02897158fc4f5fd4788c |
|
BLAKE2b-256 | 3698e73558199b993cf5fb4d4065f7185a5d157e63a2da4a2d1aa8b02947e1d4 |