tidwall / gjson

Get JSON values quickly - JSON parser for Go
MIT License
14.21k stars 847 forks source link

support result.Int() int not int64 #306

Open yingjie52 opened 1 year ago

yingjie52 commented 1 year ago

conc := gjson.Get(json, "test1.concurrency").Int()

for i := 0; i < conc; i++ 

raise error: 无效运算: i < conc(类型 int 和 int64 不匹配)

rentiansheng commented 1 year ago

you can

conc := gjson.Get(json, "test1.concurrency").Int()
for idx := int64(0); idx < cnt; idx++ {
        fmt.Println(idx)
}
package main

import "fmt"

func main() {
    cnt := int64(10)
    for idx := int64(0); idx < cnt; idx++ {
        fmt.Println(idx)
    }
}
zuozhehao commented 1 year ago
var i int64
for i = 0; i < conc; i++