package main import ( "encoding/json" "fmt" "testing" ) func TestMatchService(t *testing.T) { data := `{ "_id" : "6422d91e779467cff1a84885", "area" : "全国", "city" : "", "extracttype" : 0, "s_sha" : "d7cc66ac91dc6551991df0a37331b628de4c70973c6844f1ee6ef1c2d4e29e95", "jsondata" : { "area_city_district" : "福建", "buyer" : "莆田市第一医院", "item" : " 货物/医药品/医用材料/其他医用材料", "agency" : "福建省荔卫药械招标服务有限公司" }, "channel" : "地方公告" }` var obj map[string]interface{} if err := json.Unmarshal([]byte(data), &obj); err != nil { panic(err) } objectType := MatchService(obj) fmt.Println("objectType=>", objectType) }