MCPcopy Index your code
hub / github.com/tidwall/gjson / TestArrayValues

Function TestArrayValues

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

Source from the content-addressed store, hash-verified

1335}
1336
1337func TestArrayValues(t *testing.T) {
1338 var json = `{"array": ["PERSON1","PERSON2",0],}`
1339 values := Get(json, "array").Array()
1340 var output string
1341 for i, val := range values {
1342 if i > 0 {
1343 output += "\n"
1344 }
1345 output += fmt.Sprintf("%#v", val)
1346 }
1347 expect := strings.Join([]string{
1348 `gjson.Result{Type:3, Raw:"\"PERSON1\"", Str:"PERSON1", Num:0, ` +
1349 `Index:11, Indexes:[]int(nil)}`,
1350 `gjson.Result{Type:3, Raw:"\"PERSON2\"", Str:"PERSON2", Num:0, ` +
1351 `Index:21, Indexes:[]int(nil)}`,
1352 `gjson.Result{Type:2, Raw:"0", Str:"", Num:0, Index:31, Indexes:[]int(nil)}`,
1353 }, "\n")
1354 if output != expect {
1355 t.Fatalf("expected '%v', got '%v'", expect, output)
1356 }
1357
1358}
1359
1360func BenchmarkValid(b *testing.B) {
1361 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 2

GetFunction · 0.85
ArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…