pub fn data_to_string(data: &Value) -> StringExpand description
Convert data to a human-readable string representation
This function handles both text and binary data by detecting the type and formatting appropriately. Binary data is converted to hex representation.
§Arguments
data- The JSON value containing the data to convert
§Returns
- For text data: the original string
- For binary data: hex-encoded string with “HEX:” prefix
- For null data: “null” string
- For other types: JSON string representation
§Examples
use serde_json::json;
use agentsight_capture::analyzers::common::data_to_string;
let text_data = json!("Hello World");
assert_eq!(data_to_string(&text_data), "Hello World");
let binary_data = json!("\x00\x01\x02");
assert!(data_to_string(&binary_data).starts_with("HEX:"));