feat: Introduce JSON decoding utility functions and update error handling in Claude and OpenAI response structures

This commit is contained in:
1808837298@qq.com
2025-03-16 18:34:39 +08:00
parent a4a40c495d
commit b3b1c803fc
6 changed files with 39 additions and 14 deletions

14
common/json.go Normal file
View File

@@ -0,0 +1,14 @@
package common
import (
"bytes"
"encoding/json"
)
func DecodeJson(data []byte, v any) error {
return json.NewDecoder(bytes.NewReader(data)).Decode(v)
}
func DecodeJsonStr(data string, v any) error {
return DecodeJson(StringToByteSlice(data), v)
}