MCPcopy Index your code
hub / github.com/dmackdev/egui_json_tree

github.com/dmackdev/egui_json_tree @v0.16.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.16.0 ↗ · + Follow
177 symbols 417 edges 22 files 32 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

egui_json_tree

Latest version Total Downloads Documentation Build Status MIT Apache

An interactive JSON tree visualiser for egui, with search and highlight functionality.

Search Example

See the demo source code and webpage for detailed use cases, including:

  • Automatic expansion of arrays/objects and highlighting, based on search term matches.
  • Copying JSON paths and values to the clipboard.
  • A JSON editor UI.

Usage

let value = serde_json::json!({ "foo": "bar", "fizz": [1, 2, 3]});

// Simple:
JsonTree::new("simple-tree", &value).show(ui);

// Customised:
let response = JsonTree::new("customised-tree", &value)
     .style(
       JsonTreeStyle::new()
           .abbreviate_root(true) // Show {...} when the root object is collapsed.
           .toggle_buttons_state(ToggleButtonsState::VisibleDisabled)
           .visuals(JsonTreeVisuals {
               bool_color: Color32::YELLOW,
               ..Default::default()
           }),
     )
    .default_expand(DefaultExpand::All) // Expand all arrays/object by default.
    .on_render(|ui, ctx| {
        // Customise rendering of the JsonTree, and/or handle interactions.
        match ctx {
            RenderContext::Property(ctx) => {
                ctx.render_default(ui).context_menu(|ui| {
                    // Show a context menu when right clicking
                    // an array index or object key.
                });
            }
            RenderContext::BaseValue(ctx) => {
                // Show a button after non-recursive JSON values.
                ctx.render_default(ui);
                if ui.small_button("+").clicked() {
                    // ...
                }
            }
            RenderContext::ExpandableDelimiter(ctx) => {
                // Render array brackets and object braces as normal.
                ctx.render_default(ui);
            }
        };
    })
    .show(ui);

// By default, the tree will expand/collapse all arrays/objects
// to respect the `default_expand` setting when it changes.
// If required, you can manually trigger this reset, e.g. after a button press:
if ui.button("Reset").clicked() {
  response.reset_expanded(ui);
}

Supported JSON Types

JsonTree can visualise any type that implements value::ToJsonTreeValue.

See the table of crate features below for provided implementations.

Feature/Dependency JSON Type Default
serde_json serde_json::Value Yes
simd_json simd_json::owned::Value No

If you wish to use a different JSON type, see the value module, and disable default features in your Cargo.toml if you do not need the serde_json dependency.

Run Demo App

cargo run -p demo --release

Extension points exported contracts — how you extend this code

DefaultRender (Interface)
A trait for types that provide a default rendering implementation. [5 implementers]
egui_json_tree/src/render.rs
Show (Interface)
(no doc) [8 implementers]
demo/src/apps/mod.rs
ToJsonTreeValue (Interface)
A trait for types that can be converted to a [JsonTreeValue]. [2 implementers]
egui_json_tree/src/value.rs

Core symbols most depended-on inside this repo

default_expand
called by 18
egui_json_tree/src/tree.rs
to_json_pointer_string
called by 14
egui_json_tree/src/pointer.rs
show
called by 13
egui_json_tree/src/tree.rs
style
called by 12
egui_json_tree/src/tree.rs
render_default
called by 11
egui_json_tree/src/render.rs
append
called by 9
egui_json_tree/src/render.rs
as_ref
called by 9
egui_json_tree/src/delimiters.rs
show
called by 9
demo/src/apps/editor.rs

Shape

Method 85
Function 41
Class 33
Enum 15
Interface 3

Languages

Rust100%

Modules by API surface

egui_json_tree/src/render.rs28 symbols
demo/src/apps/editor.rs25 symbols
egui_json_tree/src/tree.rs19 symbols
egui_json_tree/src/style.rs16 symbols
egui_json_tree/src/pointer.rs13 symbols
egui_json_tree/src/search.rs8 symbols
egui_json_tree/src/node.rs7 symbols
egui_json_tree/tests/image_snapshot_tests.rs6 symbols
egui_json_tree/src/value.rs6 symbols
demo/src/main.rs6 symbols
demo/src/apps/wrapping.rs6 symbols
demo/src/apps/default_expand.rs6 symbols

For agents

$ claude mcp add egui_json_tree \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact