feat: 修复 JSON 字符串处理逻辑,确保字符串格式的有效性
This commit is contained in:
parent
79f9e36871
commit
84b3fd064c
@ -137,11 +137,11 @@ impl OpenAIProvider {
|
||||
Value::String(raw) => {
|
||||
// If the string is already valid JSON, keep it as-is
|
||||
// Otherwise, ensure it's a proper JSON string
|
||||
if serde_json::from_str::<Value>(raw).is_ok() {
|
||||
if serde_json::from_str::<Value>(&raw).is_ok() {
|
||||
Value::String(raw)
|
||||
} else {
|
||||
// Invalid JSON string - wrap it as a proper JSON string
|
||||
serde_json::to_string(&raw).unwrap_or_else(|_| "null".to_string())
|
||||
Value::String(serde_json::to_string(&raw).unwrap_or_else(|_| "null".to_string()))
|
||||
}
|
||||
}
|
||||
value => Value::String(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user