MCPcopy Create free account
hub / github.com/tidwall/gjson / TestQueryArrayValues

Function TestQueryArrayValues

gjson_test.go:1711–1732  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1709}
1710
1711func TestQueryArrayValues(t *testing.T) {
1712 json := `{
1713 "artists": [
1714 ["Bob Dylan"],
1715 "John Lennon",
1716 "Mick Jagger",
1717 "Elton John",
1718 "Michael Jackson",
1719 "John Smith",
1720 true,
1721 123,
1722 456,
1723 false,
1724 null
1725 ]
1726 }`
1727 assert(t, Get(json, `a*.#[0="Bob Dylan"]#|#`).String() == "1")
1728 assert(t, Get(json, `a*.#[0="Bob Dylan 2"]#|#`).String() == "0")
1729 assert(t, Get(json, `a*.#[%"John*"]#|#`).String() == "2")
1730 assert(t, Get(json, `a*.#[_%"John*"]#|#`).String() == "0")
1731 assert(t, Get(json, `a*.#[="123"]#|#`).String() == "1")
1732}
1733
1734func TestParenQueries(t *testing.T) {
1735 json := `{

Callers

nothing calls this directly

Calls 3

assertFunction · 0.85
GetFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…