use super::shared::report_value;
use super::ReportContext;
use crate::model::AnalysisResult;
use anyhow::{Context, Result};
use std::path::Path;
pub fn render_json(result: &AnalysisResult, root: &Path) -> Result<String> {
render_json_with_threshold(result, root, 0.0)
}
pub fn render_json_with_threshold(
result: &AnalysisResult,
root: &Path,
threshold: f64,
) -> Result<String> {
render_json_context(&ReportContext::new(result, root, threshold))
}
pub(super) fn render_json_context(context: &ReportContext<'_>) -> Result<String> {
let report = report_value(context);
serde_json::to_string_pretty(&report).context("failed to serialize JSON report")
}