Expand description
Transforms over a data Document: redact, select, filter and highlight
by JSONPath (the jsonpath feature). See crate::transform for the
pipeline.
use rich::{Console, Style};
use rich_ext::data::transform::{Document, Filter, Select};
use rich_ext::data::{parse, Format};
use rich_ext::transform::Pipeline;
let node = parse(Format::Json, r#"{"a": {"b": 1, "c": 2}, "d": [1, 2]}"#).unwrap();
let pipeline = Pipeline::new().then("filter", Filter::new("$.a.c").unwrap());
let document = pipeline.apply(Document::new(node).label("doc")).unwrap();
let out = Console::builder().width(40).build().render_export(&document.explorer());
assert_eq!(out, "doc\n└── a\n └── c: 2\n");Structs§
- Document
- A data tree on its way to being rendered, with what transforms decided about how to show it.
- Filter
- Keeps what a JSONPath selects and the containers above it, and drops the rest, so the document keeps its shape. Sequences are renumbered.
- Highlight
- Styles the tree lines of what a JSONPath selects.
- Redact
- Masks values with a
Redactor, such asRedaction::secrets. - Select
- Narrows a document to what a JSONPath selects. One hit becomes the root, labelled with its path; several (or none) become a map keyed by path.