This commit is contained in:
2025-08-06 21:29:35 +08:00
parent 43b926d668
commit f4ad8eac51
2 changed files with 80 additions and 122 deletions

View File

@@ -1,6 +1,10 @@
package lzUtils
import "github.com/bytedance/sonic"
import (
"encoding/json"
"github.com/bytedance/sonic"
)
func RecursiveParse(data interface{}) (interface{}, error) {
switch v := data.(type) {
@@ -33,3 +37,20 @@ func RecursiveParse(data interface{}) (interface{}, error) {
return v, nil
}
}
// ParseJsonResponse 直接解析JSON响应数据
// jsonResp: JSON响应数据
// Returns: 解析后的数据字节数组
func ParseJsonResponse(jsonResp []byte) ([]byte, error) {
parseResult, err := RecursiveParse(string(jsonResp))
if err != nil {
return nil, err
}
resultResp, marshalErr := json.Marshal(parseResult)
if marshalErr != nil {
return nil, err
}
return resultResp, nil
}