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
- Clone this repository
- 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
-
Navigate to the frontend directory:
cd streamlit_json_tip/frontend
-
Install dependencies:
npm install -
Start development server:
npm start -
In your Python code, set
_RELEASE = Falsein__init__.py
Building for Production
-
Build the frontend:
cd streamlit_json_tip/frontend npm run build
-
Set
_RELEASE = Truein__init__.py -
Build the package:
python setup.py sdist bdist_wheel
Running the Example
streamlit run example_app.py
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb64bfaacb9e24f9298cdaf5c9767278b22c4258357635508e2ab7f10964e29d
|
|
| MD5 |
53163f354292111d9440bf90ef22afbb
|
|
| BLAKE2b-256 |
e46635a0726998a6ac55af9897d58fd8751494436e20aebb53eaf5bb3a9d6e91
|
File details
Details for the file streamlit_json_tip-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_json_tip-0.1.0-py3-none-any.whl
- Upload date:
- Size: 653.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b31d42221a71906f54afce696e792e243360a54bd45305a403e1fdc107247514
|
|
| MD5 |
e5eff3242b17a8a4bd97cd394352c0f9
|
|
| BLAKE2b-256 |
27ae23c596dd05b6bb91fc35d208717e6c56dd011df5ba9f1272a5fb93abd271
|