Skip to content

Commit

Permalink
update: use newDecoder instead manual parse
Browse files Browse the repository at this point in the history
  • Loading branch information
1umine committed Aug 22, 2023
1 parent 25bef21 commit ea28d47
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions client/http_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"net/url"
"regexp"
"strconv"
"strings"

"github.com/pkg/errors"

Expand Down Expand Up @@ -73,25 +72,8 @@ func (c *QQClient) GetGroupHonorInfo(groupCode int64, honorType HonorType) (*Gro
if len(matched) == 0 {
return nil, errors.New("无匹配结果")
}
matchedString := utils.B2S(matched[1]) // "{..."
var builder strings.Builder
var s string
end := 0
for _, c := range matchedString {
s = string(c)
builder.WriteString(s)
switch s {
case "{":
end++
case "}":
end--
}
if end == 0 {
break
}
}
ret := GroupHonorInfo{}
err = json.Unmarshal(utils.S2B(builder.String()), &ret)
err = json.NewDecoder(bytes.NewReader(matched[1])).Decode(&ret)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ea28d47

Please sign in to comment.