MCPcopy
hub / github.com/tidwall/gjson / TestArrayKeys

Function TestArrayKeys

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

Source from the content-addressed store, hash-verified

2488}
2489
2490func TestArrayKeys(t *testing.T) {
2491 N := 100
2492 json := "["
2493 for i := 0; i < N; i++ {
2494 if i > 0 {
2495 json += ","
2496 }
2497 json += fmt.Sprint(i)
2498 }
2499 json += "]"
2500 var i int
2501 Parse(json).ForEach(func(key, value Result) bool {
2502 assert(t, key.String() == fmt.Sprint(i))
2503 assert(t, key.Int() == int64(i))
2504 i++
2505 return true
2506 })
2507 assert(t, i == N)
2508}
2509
2510func TestToFromStr(t *testing.T) {
2511 json := `{"Message":"{\"Records\":[{\"eventVersion\":\"2.1\"}]"}`

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
assertFunction · 0.85
ForEachMethod · 0.80
IntMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…