Skip to main content

A Streamlit custom component for viewing JSON with interactive tooltips and tags

Project description

Streamlit JSON Tip

A Streamlit custom component for viewing JSON data with interactive tooltips and tags for individual fields.

Features

  • 🔍 Interactive JSON Viewer: Expand/collapse objects and arrays
  • 📝 Interactive Tooltips: Add contextual help for any field with professional Tippy.js tooltips
  • 🏷️ Field Tags: Categorize fields with colored tags (PII, CONFIG, etc.)
  • 🎯 Field Selection: Click on fields to get detailed information
  • 🎨 Syntax Highlighting: Color-coded JSON with proper formatting
  • 📱 Responsive Design: Works well in different screen sizes

Installation

  1. Clone this repository
  2. Install in development mode:
    pip install -e .
    

Usage

import streamlit as st
from streamlit_json_tip import json_viewer

# Your JSON data
data = {
    "user": {
        "id": 123,
        "name": "John Doe",
        "email": "john@example.com"
    }
}

# Help text for specific fields
help_text = {
    "user.id": "Unique user identifier",
    "user.name": "Full display name",
    "user.email": "Primary contact email"
}

# Tags for categorizing fields
tags = {
    "user.id": "ID",
    "user.name": "PII",
    "user.email": "PII"
}

# Display the JSON viewer
selected = json_viewer(
    data=data,
    help_text=help_text,
    tags=tags,
    height=400
)

# Handle field selection
if selected:
    st.write(f"Selected field: {selected['path']}")
    st.write(f"Value: {selected['value']}")
    if selected.get('help_text'):
        st.write(f"Help: {selected['help_text']}")

Parameters

  • data (dict): The JSON data to display
  • help_text (dict, optional): Dictionary mapping field paths to help text
  • tags (dict, optional): Dictionary mapping field paths to tags/labels
  • height (int, optional): Height of the component in pixels (default: 400)
  • key (str, optional): Unique key for the component

Field Path Format

Field paths use dot notation for objects and bracket notation for arrays:

  • "user.name" - Object field
  • "items[0].title" - Array item field
  • "settings.preferences.theme" - Nested object field

Development

Frontend Development

  1. Navigate to the frontend directory:

    cd streamlit_json_tip/frontend
    
  2. Install dependencies:

    npm install
    
  3. Start development server:

    npm start
    
  4. In your Python code, set _RELEASE = False in __init__.py

Building for Production

  1. Build the frontend:

    cd streamlit_json_tip/frontend
    npm run build
    
  2. Set _RELEASE = True in __init__.py

  3. Build the package:

    python setup.py sdist bdist_wheel
    

Running the Example

streamlit run example_app.py

License

MIT 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

streamlit_json_tip-0.1.0.tar.gz (651.9 kB view details)

Uploaded Source

Built Distribution

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

streamlit_json_tip-0.1.0-py3-none-any.whl (653.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for streamlit_json_tip-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb64bfaacb9e24f9298cdaf5c9767278b22c4258357635508e2ab7f10964e29d
MD5 53163f354292111d9440bf90ef22afbb
BLAKE2b-256 e46635a0726998a6ac55af9897d58fd8751494436e20aebb53eaf5bb3a9d6e91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_json_tip-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b31d42221a71906f54afce696e792e243360a54bd45305a403e1fdc107247514
MD5 e5eff3242b17a8a4bd97cd394352c0f9
BLAKE2b-256 27ae23c596dd05b6bb91fc35d208717e6c56dd011df5ba9f1272a5fb93abd271

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