1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! An interactive JSON tree visualiser for [`egui`](https://github.com/emilk/egui), with search and highlight functionality.
//!
//! See the demo [source code](https://github.com/dmackdev/egui_json_tree/blob/main/demo) and [webpage](https://dmackdev.github.io/egui_json_tree) 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
//! ```rust
//! # use egui::{Color32};
//! # use egui_json_tree::{
//! # render::{
//! # DefaultRender, RenderBaseValueContext, RenderContext, RenderExpandableDelimiterContext,
//! # RenderPropertyContext,
//! # },
//! # DefaultExpand, JsonTree, JsonTreeStyle, JsonTreeVisuals, ToggleButtonsState
//! # };
//! # egui::__run_test_ui(|ui| {
//! 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 [`ToJsonTreeValue`](trait@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`](mod@value) module,
//! and disable default features in your `Cargo.toml` if you do not need the `serde_json` dependency.
pub use DefaultExpand;
pub use JsonTreeResponse;
pub use ;
pub use ToggleButtonsState;
pub use JsonTree;