Skip to main content

A python-native fx-alike terminal JSON viewer with JSONPath Integration.

Project description

pyfx

Build Status Documentation Status PyPI version GitHub Pipenv locked Python version GitHub

Inspired by fx, a python implementation of JSON Viewer TUI.

Installation

Use pip

Before using pip, please check your Python version, pyfx requires >= 3.8.

pip install python-fx

Build From Source

Clone the this repo, change directory into the project and run

python setup.py install

Usage

CLI

pyfx comes with a CLI, which you can use to directly open a JSON file.
After installation, simply run

pyfx JSON_FILE

Import as Module

Import pyfx Simple TUI

You can directly integrate pyfx's TUI into your own project.
One would expect this to be the last step of your CLI application. The method Controller#run_with_data contains a infinite loop MainLoop to render image until exit (press q).

from pyfx import Controller

...
# data is the what you want to render as TUI
# only supports dict, list and primitive variable
Controller().run_with_data(data)

Import pyfx's Native JSON Library and Integrate with Your Own TUI

You can also import pyfx native JSON lib to integrate it into your own urwid TUI, e.g. view_window.py.

from pyfx.view.json_lib import JSONListBox, JSONListWalker, NodeFactory

...
# create top node from the data (only supports dict, list and primitive variable)
top_node = NodeFactory.create_node("", data, display_key=False)
# create JSONListBox from top node, a urwid ListBox compatible widget (http://urwid.org/reference/widget.html#listbox)
listbox = JSONListBox(JSONListWalker(top_node))
# use listbox in your own TUI 
...

Key Mappings

Key Function
Main Window
q exit pyfx
View Window
enter toggle expansion
up/ctrl p move cursor up one line
down/ctrl n move cursor down one line
Query Window
. enter query window (used to input JSONPath query)
enter apply JSONPath query and switch to View Window
esc apply JSONPath query and exit Query Window

Full Documentation

Please visit Documentation

License

Please visit LICENSE

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

python-fx-0.1.0a2.tar.gz (26.4 kB view hashes)

Uploaded Source

Built Distribution

python_fx-0.1.0a2-py3-none-any.whl (31.2 kB view hashes)

Uploaded Python 3

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