json_highlight_writer/
lib.rs1use json::JsonValue;
2use colored::*;
3
4mod generator;
5mod highlight_color;
6mod highlight;
7
8pub fn highlight(json_object: &JsonValue, mut slices: Vec<&JsonValue>) -> String {
9 let mut gen = highlight::HighlightGenerator::new();
10 gen.write_json_with_highlight(
11 json_object, &mut slices
12 ).expect("Can't fail");
13 gen.consume()
14}
15
16pub fn highlight_with_colors(json_object: &JsonValue, mut slices: Vec<&JsonValue>, colors: Vec<Color>) -> String {
17 let mut gen = highlight::HighlightGenerator::new_with_colors(colors);
18 gen.write_json_with_highlight(
19 json_object, &mut slices
20 ).expect("Can't fail");
21 gen.consume()
22}
23
24pub fn highlight_with_colors_and_remainder(json_object: &JsonValue, mut slices: Vec<&JsonValue>, colors: Option<Vec<Color>>, remainder_color: Option<Color>) -> String {
25 let mut gen = highlight::HighlightGenerator::new_with_colors_and_remainder(colors, remainder_color);
26 gen.write_json_with_highlight(
27 json_object, &mut slices
28 ).expect("Can't fail");
29 gen.consume()
30}