优化字符串匹配
This commit is contained in:
parent
5cb1fa20d5
commit
c2bcab795d
@ -217,11 +217,12 @@ func (dj *DynamicJSON) extraSliceIndex(key string) (bool, int) {
|
||||
// slice 至少是 [1] 格式
|
||||
return false, 0
|
||||
}
|
||||
// 不用正则,直接字符串处理
|
||||
strByte := []byte(key)
|
||||
if string(strByte[0:1]) != "[" || string(strByte[len(strByte)-1:]) != "]" {
|
||||
|
||||
if !strings.HasPrefix(key, "[") || !strings.HasSuffix(key, "]") {
|
||||
return false, 0
|
||||
}
|
||||
// 不用正则,直接字符串处理
|
||||
strByte := []byte(key)
|
||||
index, err := strconv.Atoi(string(strByte[1 : len(strByte)-1]))
|
||||
if nil != err {
|
||||
return false, 0
|
||||
|
Loading…
Reference in New Issue
Block a user