Skip to main content

A simple JSON/tree viewer desktop app built on Cacao

Project description

🍫 cacao-json-viewer

A tiny desktop app to view JSON as an interactive tree using Cacao.

Installation

pip install cacao-json-viewer

Usage

Command Line Interface

# From a file
cacao-json-viewer path/to/data.json

# Or via stdin
cat data.json | cacao-json-viewer

Programmatic Usage 🍫

Now with simplified imports! Use the package directly in your Python code:

Basic Example

import json
from cacao_json_viewer import preview_json

def main():
    # Load your JSON data
    with open("data.json", "r") as f:
        data = json.load(f)
    
    # Preview it in a desktop window
    preview_json(data, title="My JSON Data")

if __name__ == "__main__":
    main()

Alternative Import Syntax

import json
from cacao_json_viewer import preview  # Even cleaner!

def main():
    data = {
        "name": "John Doe",
        "age": 30,
        "skills": ["Python", "JavaScript", "SQL"],
        "address": {
            "street": "123 Main St",
            "city": "New York",
            "zipcode": "10001"
        }
    }
    
    # Same function, cleaner name
    preview(data, title="User Profile", width=900, height=700)

if __name__ == "__main__":
    main()

Working with API Data

import json
import requests
from cacao_json_viewer import preview_json

def main():
    # Fetch data from an API
    response = requests.get("https://api.example.com/data")
    data = response.json()
    
    # Preview the API response
    preview_json(data, title="API Response")

if __name__ == "__main__":
    main()

Function Parameters

preview_json(
    data,                           # Your JSON data (dict, list, or any JSON-serializable object)
    title="Cacao JSON Viewer",     # Window title
    width=800,                      # Window width in pixels
    height=600,                     # Window height in pixels
)

Features

  • 🍫 Simple & Clean: Minimal setup, maximum functionality
  • 🌳 Interactive Tree View: Expand/collapse JSON nodes
  • 🖥️ Desktop Application: Native desktop window using Cacao
  • 📦 Easy Import: Clean import syntax - from cacao_json_viewer import preview_json

Requirements

  • Python 3.8+
  • Cacao framework

License

MIT

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

cacao_json_viewer-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cacao_json_viewer-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file cacao_json_viewer-0.1.0.tar.gz.

File metadata

  • Download URL: cacao_json_viewer-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for cacao_json_viewer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e13a4559fbd4873b33db1b48e1f443616be8efc95c40c65fe5ec107e230b003
MD5 966c406ff79c29879abcdfccc7e2708a
BLAKE2b-256 f487249b6135446dc79a7a3aad95b1522dd35143ae9a096be2c938da24288fe7

See more details on using hashes here.

File details

Details for the file cacao_json_viewer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cacao_json_viewer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 892ff55473768aef9e454a4515909a568c2172d20a20f2c9b17988cee53c5073
MD5 4d271ff5bba2703aa1bcbec865f16de5
BLAKE2b-256 0c7fd22ba45896a0c9e85f23cd6fa7f999294dd4915dff947a11c6eddf9f3d16

See more details on using hashes here.

Supported by

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