Skip to main content

Visualize and edit JSON

Project description

💥py-jsoneditor💥

Quickly View and Edit any JSON data.

Why?

When working with JSON data, you offten need to get a structured view of the JSON in order to be able to work with it. There's an online tool https://jsoneditoronline.org/ which i used for this, but copying/pasting all the time got frustrating pretty quickly, This is why i created this package which you can launch right from python or from the command line.

Screenshot

Installation

pip install jsoneditor

Python example

In python you can simply import jsoneditor and call the editjson function, the first argument is going to be the data. See Formats you can pass the JSON as for all the formats you can pass the JSON in. See Python api for a full list of addtional arguments that you can pass to editjson.

import requests
import jsoneditor

data = requests.get('https://jsonplaceholder.typicode.com/comments').json()
jsoneditor.editjson(data)

Command line example

From the command line you can either pass the data as an argument as so:

jsoneditor '{"Hey": "Hi"}'

Or you can pipe it in like so:

curl https://jsonplaceholder.typicode.com/comments | jsoneditor

Or you can use what you have in your clipboard like so:

jsoneditor -c

See Formats you can pass the JSON as for all the formats you can pass the JSON in.

Refer to CLI options for a list of all cli options. Alternatively you can run jsoneditor --help from your terminal to see it.

Formats you can pass the JSON as

You can pass the json in any of the following formats:

  • as valid json string. Example: {"Hey": "Hi"}
  • as a python dict. Example: {'Hey': 'hi'}
  • as a url the points to valid json. Example: https://jsonplaceholder.typicode.com/comments
  • as a file path that is valid json. Example: data.json

Python Api

parameter type optional description
data Any The data in any of these formats.
callback callable ✔️ If you provide this argument you will have a ✅ button which will trigger this callback.
options dict ✔️ Options to pass the the jsoneditor object. See here
keep_running bool ✔️ Whether to keep the server running. Defaults to False.
run_in_thread bool ✔️ Whether to run the server in a separate thread. Defaults to False.
is_csv bool ✔️ Whether the data is csv data. Defaults to False.
title str ✔️ A title to display in the browser.
port int ✔️ specify which port to use.

CLI options

parameter description
data The data in any of these formats.
-o Add a button that will output the json back to the console.
-b Keep running in backround.
-c Get JSON input from clipboard.
-k Keep alive.
-e Edit mode.
-p Server port.
--out File to output when in edit mode.
-t Title to display in browser window.
--csv Input is CSV.

Build

python setup.py sdist

Acknowledgements

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

jsoneditor-1.4.0.tar.gz (256.8 kB view details)

Uploaded Source

File details

Details for the file jsoneditor-1.4.0.tar.gz.

File metadata

  • Download URL: jsoneditor-1.4.0.tar.gz
  • Upload date:
  • Size: 256.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for jsoneditor-1.4.0.tar.gz
Algorithm Hash digest
SHA256 f129f64bc0f64c5e20c4f1a99f25dbf9ddfaf50a07c6a386517912868fb6aec9
MD5 7482889ff399e80c033b2fa984e13b34
BLAKE2b-256 d95aef065fc626285a4220c2b7c54de6999f3c6a689d4613009f6bda7a6d5b3b

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