From 1303e83611cccaa969ec75ad01decbb4ce192795 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Tue, 29 Nov 2016 18:08:02 -0700 Subject: [PATCH] fix lead comma error --- gjson.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gjson.go b/gjson.go index 7698a1a..f538bfa 100644 --- a/gjson.go +++ b/gjson.go @@ -1099,13 +1099,14 @@ func parseArray(c *parseContext, i int, path string) (int, bool) { if rp.alogok { var jsons = make([]byte, 0, 64) 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) if res.Exists() { - if j > 0 { + if k > 0 { jsons = append(jsons, ',') } jsons = append(jsons, []byte(res.Raw)...) + k++ } } jsons = append(jsons, ']')