Socket
Socket
Sign inDemoInstall

jsoneditor

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsoneditor

Visualize and edit JSON


Maintainers
1

Readme

💥py-jsoneditor💥

Quickly View and Edit any JSON data.

Why?

When working with JSON data, You often 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

parametertypeoptionaldescription
dataAnyThe data in any of these formats.
callbackcallable✔️If you provide this argument you will have a ✅ button which will trigger this callback.
optionsdict✔️Options to pass the the jsoneditor object. See here
additional_jsstr✔️You can pass some JavaScript to run on the client side. You can interact with the editor by accessing the window.editor variable.
keep_runningbool✔️Whether to keep the server running. Defaults to False.
run_in_threadbool✔️Whether to run the server in a separate thread. Defaults to False.
is_csvbool✔️Whether the data is csv data. Defaults to False.
is_yamlbool✔️Whether the data is yaml data. Defaults to False.
is_ndjsonbool✔️Whether the data is Newline Delimited JSON . Defaults to False.
is_js_objectbool✔️Whether the data is a JavaScript Object. Defaults to False.
titlestr✔️A title to display in the browser.
portint✔️specify which port to use.

CLI options

parameterdescription
dataThe data in any of these formats
-oAdd a button that will output the json back to the console
-bKeep running in background
-cGet JSON input from clipboard
-kKeep alive
-eEdit mode
-nDon't launch browser
-pServer port
--outFile to output when in edit mode
-tTitle to display in browser window
--csvInput is CSV
--yamlInput is YAML
--jsInput is a JavaScript Object
--ndjsonInput is Newline Delimited JSON

Build

python setup.py sdist

Acknowledgements

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc