sanitize_json

Function sanitize_json 

Source
pub fn sanitize_json(value: &Value) -> Value
Expand description

Sanitize a JSON value by redacting sensitive fields

This function recursively traverses a JSON structure and replaces values of sensitive fields with “[REDACTED]”.

§Examples

use serde_json::json;
use agents_core::security::sanitize_json;

let input = json!({
    "username": "john",
    "password": "secret123",
    "api_key": "sk-1234567890"
});

let sanitized = sanitize_json(&input);
assert_eq!(sanitized["username"], "john");
assert_eq!(sanitized["password"], "[REDACTED]");
assert_eq!(sanitized["api_key"], "[REDACTED]");