pub fn format<T: Serialize>(data: &T) -> Result<String>Expand description
Format data as JSON.
Uses pretty-printing with 2-space indentation.
§Errors
Returns an error if JSON serialization fails (e.g., if the data contains non-serializable types or custom serialization fails).
§Examples
use serde::Serialize;
use mcp_execution_cli::formatters::json;
#[derive(Serialize)]
struct Data { value: i32 }
let data = Data { value: 42 };
let json = json::format(&data).unwrap();
assert!(json.contains("42"));