Fix missing raw result for array counts

This commit is contained in:
tidwall 2019-06-30 04:48:53 -07:00
parent 3b5bf6bb5e
commit d7c940e593
2 changed files with 6 additions and 1 deletions

View File

@ -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
} }

View File

@ -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")
}