forked from mirror/gjson
Fix missing raw result for array counts
This commit is contained in:
parent
3b5bf6bb5e
commit
d7c940e593
3
gjson.go
3
gjson.go
|
@ -1446,9 +1446,10 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
|
||||||
if rp.alogok {
|
if rp.alogok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c.value.Raw = ""
|
|
||||||
c.value.Type = Number
|
c.value.Type = Number
|
||||||
c.value.Num = float64(h - 1)
|
c.value.Num = float64(h - 1)
|
||||||
|
c.value.Raw = strconv.Itoa(h - 1)
|
||||||
c.calcd = true
|
c.calcd = true
|
||||||
return i + 1, true
|
return i + 1, true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1911,3 +1911,7 @@ func TestSubSelectors(t *testing.T) {
|
||||||
assert(t, Get(json, "info.friends.#.[first,extra.0]").String() ==
|
assert(t, Get(json, "info.friends.#.[first,extra.0]").String() ==
|
||||||
`[["Dale",10],["Roger",40]]`)
|
`[["Dale",10],["Roger",40]]`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArrayCountRawOutput(t *testing.T) {
|
||||||
|
assert(t, Get(`[1,2,3,4]`, "#").Raw == "4")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue