#egui #json #tree #search #interactive #highlight #json-response

egui_json_tree

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

6 releases (breaking)

0.5.1 Apr 29, 2024
0.5.0 Mar 26, 2024
0.4.0 Feb 5, 2024
0.3.0 Jan 8, 2024
0.1.0 Sep 28, 2023

#180 in GUI

Download history 249/week @ 2024-01-25 305/week @ 2024-02-01 90/week @ 2024-02-08 91/week @ 2024-02-15 62/week @ 2024-02-22 69/week @ 2024-02-29 83/week @ 2024-03-07 71/week @ 2024-03-14 217/week @ 2024-03-21 71/week @ 2024-03-28 57/week @ 2024-04-04 14/week @ 2024-04-11 17/week @ 2024-04-18 156/week @ 2024-04-25 86/week @ 2024-05-02 15/week @ 2024-05-09

276 downloads per month

MIT/Apache

41KB
900 lines

egui_json_tree

Latest version Documentation Build Status MIT Apache

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

Search Example

Usage

use egui::{Color32};
use egui_json_tree::{DefaultExpand, JsonTree, JsonTreeStyle};

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 {
        bool_color: Color32::YELLOW,
        ..Default::default()
    })
    .default_expand(DefaultExpand::All)
    .response_callback(|response, json_pointer_string| {
      // Handle interactions within the JsonTree.
    })
    .abbreviate_root(true) // Show {...} when the root object is collapsed.
    .show(ui);

// Reset the expanded state of all arrays/objects to respect the `default_expand` setting.
response.reset_expanded(ui);

See demo.rs and run the examples for more detailed use cases, including the search match highlight/auto expand functionality, and how to copy JSON paths and values to the clipboard.

JsonTree can visualise any type that implements value::ToJsonTreeValue. Implementations to support serde_json::Value (enabled by default by the crate feature serde_json) and simd_json::owned::Value (optionally enabled by the crate feature simd_json) are provided with this crate. 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 Examples

cargo run --example=demo

Dependencies

~5–11MB
~110K SLoC