mirror of https://github.com/tidwall/gjson.git
fix lead comma error
This commit is contained in:
parent
1a15b54bbb
commit
1303e83611
5
gjson.go
5
gjson.go
|
@ -1099,13 +1099,14 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
|
||||||
if rp.alogok {
|
if rp.alogok {
|
||||||
var jsons = make([]byte, 0, 64)
|
var jsons = make([]byte, 0, 64)
|
||||||
jsons = append(jsons, '[')
|
jsons = append(jsons, '[')
|
||||||
for j := 0; j < len(alog); j++ {
|
for j, k := 0, 0; j < len(alog); j++ {
|
||||||
res := Get(c.json[alog[j]:], rp.alogkey)
|
res := Get(c.json[alog[j]:], rp.alogkey)
|
||||||
if res.Exists() {
|
if res.Exists() {
|
||||||
if j > 0 {
|
if k > 0 {
|
||||||
jsons = append(jsons, ',')
|
jsons = append(jsons, ',')
|
||||||
}
|
}
|
||||||
jsons = append(jsons, []byte(res.Raw)...)
|
jsons = append(jsons, []byte(res.Raw)...)
|
||||||
|
k++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsons = append(jsons, ']')
|
jsons = append(jsons, ']')
|
||||||
|
|
Loading…
Reference in New Issue