Skip to main content

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:

# if you have your Python3 scripts added to your path, use this one:
json4tree input.json output.json

# otherwise, use this one:
python3 -m json4tree input.json output.json

If you need to import it as a module in your Python3 script, do it like so:

# import the necessary modules
import json
import json4tree

# import your JSON data
infile = open("input.json", "r")
json_file = json.load(infile)
infile.close()

# create a new handler
converter = json4tree.handler(json_file)

# You can either print your results...
converter.results

# Or you can save your results
outfile = open("output.json", "w")
outfile.write(converter.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

json4tree-1.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

json4tree-1.0.2-py2.py3-none-any.whl (4.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file json4tree-1.0.2.tar.gz.

File metadata

  • Download URL: json4tree-1.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for json4tree-1.0.2.tar.gz
Algorithm Hash digest
SHA256 addb4315021bb7256ca9ef8569cedc53ee04760a63fa0270110b3c68a36c2921
MD5 1ee95b79ca6147d9e4fbed6bfbdfdd8f
BLAKE2b-256 315198b4889469e31938d2484e4617d4482eb328b922703fc52da15bd322be21

See more details on using hashes here.

File details

Details for the file json4tree-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: json4tree-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for json4tree-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6221affa15c221d13eda9486115bb26b29c756966bbb8ad6d37c0227cd57a217
MD5 256522221d5437f6e226103a347cdaeb
BLAKE2b-256 4d6009fbcd677e5e7f4a82943764c68cfa95f886eed636c694eefbca9fda346e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page