use super::super::OAuthError; use serde::{Serialize, de::DeserializeOwned}; pub fn to_json(value: &T) -> Result { serde_json::to_value(value).map_err(|e| { tracing::error!("JSON serialization error: {}", e); OAuthError::ServerError("Internal serialization error".to_string()) }) } pub fn from_json(value: serde_json::Value) -> Result { serde_json::from_value(value).map_err(|e| { tracing::error!("JSON deserialization error: {}", e); OAuthError::ServerError("Internal data corruption".to_string()) }) }