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

Function TestModDig

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

Source from the content-addressed store, hash-verified

2651}
2652
2653func TestModDig(t *testing.T) {
2654 json := `
2655 {
2656
2657 "group": {
2658 "issues": [
2659 {
2660 "fields": {
2661 "labels": [
2662 "milestone_1",
2663 "group:foo",
2664 "plan:a",
2665 "plan:b"
2666 ]
2667 },
2668 "refid": "123"
2669 },{
2670 "fields": {
2671 "labels": [
2672 "milestone_2",
2673 "group:foo",
2674 "plan:a",
2675 "plan"
2676 ]
2677 },
2678 "refid": "456"
2679 },[
2680 {"extra_deep":[{
2681 "fields": {
2682 "labels": [
2683 "milestone_3",
2684 "group:foo",
2685 "plan:a",
2686 "plan"
2687 ]
2688 },
2689 "refid": "789"
2690 }]
2691 }]
2692 ]
2693 }
2694 }
2695 `
2696 assert(t, Get(json, "group.@dig:#(refid=123)|0.fields.labels.0").String() == "milestone_1")
2697 assert(t, Get(json, "group.@dig:#(refid=456)|0.fields.labels.0").String() == "milestone_2")
2698 assert(t, Get(json, "group.@dig:#(refid=789)|0.fields.labels.0").String() == "milestone_3")
2699 json = `
2700 { "something": {
2701 "anything": {
2702 "abcdefg": {
2703 "finally": {
2704 "important": {
2705 "secret": "password",
2706 "name": "jake"
2707 }
2708 },
2709 "name": "melinda"
2710 }

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…