package main import ( "io/ioutil" "testing" "474420502.top/eson/gjson" ) func TestTaskEx_Execute(t *testing.T) { data, err := ioutil.ReadFile("../search.json") if err != nil { panic(err) } var adDataList []string if gjson.Valid(string(data)) { P := gjson.Parse(string(data)) data := P.Get(`data`) if data.Exists() { adData := data.Get(`#[label = "广告"]#`) if adData.Exists() { for _, result := range adData.Array() { adDataList = append(adDataList, result.String()) } } else { t.Error(`expr error`) } } } if len(adDataList) == 1 { t.Error("adDataList != 1") t.Error(adDataList) } }