如何在对象中获取过滤结果

时间:2019-05-23 11:29:17

标签: javascript json typescript

我正在设置返回包含查询结果的Javascript对象。

const input = [{
    "Id": 1,
    "Category": "EA Name",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "eAId",
    "Values": [{
      "Key": "616",
      "Value": "Richmond-Petersburg VA",
      "CategoryId": 1
    }, {
      "Key": "714",
      "Value": "Erie PA",
      "CategoryId": 1
    }, {
      "Key": "730",
      "Value": "Richland-Kennewick-Pasco WA",
      "CategoryId": 1
    }]
  },{
    "Id": 2,
    "Category": "Region",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "regionId",
    "Values": [{
      "Key": "608",
      "Value": "Mid-Atlantic",
      "CategoryId": 2
    }]
  }, {
    "Id": 3,
    "Category": "Tower Owner",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "towerOwnerId",
    "Values": [ {
      "Key": "10447",
      "Value": "WaterTank",
      "CategoryId": 4
    }]
  }, {
    "Id": 5,
    "Category": "SA/A&E Vendor",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "sAAEVendorId",
    "Values": [{
      "Key": "1396",
      "Value": "FDH",
      "CategoryId": 5
    }, {
      "Key": "3547",
      "Value": "Not Specified",
      "CategoryId": 5
    },]
  }, {
    "Id": 6,
    "Category": "OEM",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "oEMVendorId",
    "Values": [{
      "Key": "3547",
      "Value": "Not Specified",
      "CategoryId": 6
    }, {
      "Key": "3601",
      "Value": "Ericsson",
      "CategoryId": 6
    }, {
      "Key": "3603",
      "Value": "Nokia",
      "CategoryId": 6
    }]
  }];

  var resultSet = Json.filter(it =>
  {
    it.Values.filter(it2 => it2.includes("Rich"));
  });

我期望得到这样的对象作为回报,但是它返回一个空数组。

[
  {
    "Id": 1,
    "Category": "EA Name",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "eAId",
    "Values": [
      {
        "Key": "616",
        "Value": "Richmond-Petersburg VA",
        "CategoryId": 1
      }
    ]
  }
]

3 个答案:

答案 0 :(得分:0)

您无法运行it2.includes,因为它将成为对象,因此您需要尝试it2.Value.toLowerCase().includes('rich')it2.Value.includes('Rich')

You should try this:

var resultSet = Json.map(it => ({
    ...it,
    Values: it.Values.filter(it2 => it2.Value.toLowerCase().includes('rich'))
}))
.filter(it => it.Values.length)

答案 1 :(得分:0)

值是一个对象数组。您要传递给第二个过滤器函数的参数是一个字符串。因此,该函数正在其项目中查找字符串“ Rich”。您需要指定要匹配的特定道具。 Array.includes也需要完全匹配。

答案 2 :(得分:0)

使用reducefilter。将过滤器应用于Values数组,并查看Value属性是否包含Rich

const input = [{
    "Id": 1,
    "Category": "EA Name",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "eAId",
    "Values": [{
      "Key": "616",
      "Value": "Richmond-Petersburg VA",
      "CategoryId": 1
    }, {
      "Key": "617",
      "Value": "Staunton VA-WV",
      "CategoryId": 1
    }, {
      "Key": "618",
      "Value": "Roanoke VA-NC-WV",
      "CategoryId": 1
    }, {
      "Key": "619",
      "Value": "Greensboro-Winston-Salem NC-VA",
      "CategoryId": 1
    }, {
      "Key": "620",
      "Value": "Raleigh-Durham-Chapel Hill NC",
      "CategoryId": 1
    }, {
      "Key": "621",
      "Value": "Norfolk-Virginia Beach VA-NC",
      "CategoryId": 1
    }, {
      "Key": "622",
      "Value": "Greenville NC",
      "CategoryId": 1
    }, {
      "Key": "623",
      "Value": "Fayetteville NC",
      "CategoryId": 1
    }, {
      "Key": "624",
      "Value": "Charlotte-Gastonia NC-SC",
      "CategoryId": 1
    }, {
      "Key": "625",
      "Value": "Columbia SC",
      "CategoryId": 1
    }, {
      "Key": "626",
      "Value": "Wilmington NC-SC",
      "CategoryId": 1
    }, {
      "Key": "627",
      "Value": "Charleston-North Charleston SC",
      "CategoryId": 1
    }, {
      "Key": "628",
      "Value": "Augusta-Aiken GA-SC",
      "CategoryId": 1
    }, {
      "Key": "629",
      "Value": "Savannah GA-SC",
      "CategoryId": 1
    }, {
      "Key": "630",
      "Value": "Charleston WV-KY-OH",
      "CategoryId": 1
    }, {
      "Key": "631",
      "Value": "Cincinnati-Hamilton OH-KY-IN",
      "CategoryId": 1
    }, {
      "Key": "632",
      "Value": "Dayton-Springfield OH",
      "CategoryId": 1
    }, {
      "Key": "633",
      "Value": "Columbus OH",
      "CategoryId": 1
    }, {
      "Key": "634",
      "Value": "Wheeling WV-OH",
      "CategoryId": 1
    }, {
      "Key": "635",
      "Value": "Cleveland-Akron OH-PA",
      "CategoryId": 1
    }, {
      "Key": "636",
      "Value": "Toledo OH",
      "CategoryId": 1
    }, {
      "Key": "637",
      "Value": "Detroit-Ann Arbor-Flint MI",
      "CategoryId": 1
    }, {
      "Key": "638",
      "Value": "Northern Michigan MI",
      "CategoryId": 1
    }, {
      "Key": "639",
      "Value": "Green Bay WI-MI",
      "CategoryId": 1
    }, {
      "Key": "640",
      "Value": "Appleton-Oshkosh-Neenah WI",
      "CategoryId": 1
    }, {
      "Key": "641",
      "Value": "Traverse City MI",
      "CategoryId": 1
    }, {
      "Key": "642",
      "Value": "Grand Rapids-Muskegon MI",
      "CategoryId": 1
    }, {
      "Key": "643",
      "Value": "Milwaukee-Racine WI",
      "CategoryId": 1
    }, {
      "Key": "644",
      "Value": "Chicago-Gary-Kenosha IL-IN-WI",
      "CategoryId": 1
    }, {
      "Key": "645",
      "Value": "Elkhart-Goshen IN-MI",
      "CategoryId": 1
    }, {
      "Key": "646",
      "Value": "Fort Wayne IN",
      "CategoryId": 1
    }, {
      "Key": "647",
      "Value": "Indianapolis IN-IL",
      "CategoryId": 1
    }, {
      "Key": "648",
      "Value": "Champaign-Urbana IL",
      "CategoryId": 1
    }, {
      "Key": "649",
      "Value": "Evansville-Henderson IN-KY-IL",
      "CategoryId": 1
    }, {
      "Key": "650",
      "Value": "Tulsa OK-KS",
      "CategoryId": 1
    }, {
      "Key": "651",
      "Value": "Oklahoma City OK",
      "CategoryId": 1
    }, {
      "Key": "652",
      "Value": "Western Oklahoma OK",
      "CategoryId": 1
    }, {
      "Key": "653",
      "Value": "Dallas-Fort Worth TX-AR-OK",
      "CategoryId": 1
    }, {
      "Key": "654",
      "Value": "Abilene TX",
      "CategoryId": 1
    }, {
      "Key": "655",
      "Value": "San Angelo TX",
      "CategoryId": 1
    }, {
      "Key": "656",
      "Value": "Austin-San Marcos TX",
      "CategoryId": 1
    }, {
      "Key": "657",
      "Value": "Houston-Galveston-Brazoria TX",
      "CategoryId": 1
    }, {
      "Key": "658",
      "Value": "Corpus Christi TX",
      "CategoryId": 1
    }, {
      "Key": "659",
      "Value": "McAllen-Edinburg-Mission TX",
      "CategoryId": 1
    }, {
      "Key": "660",
      "Value": "San Antonio TX",
      "CategoryId": 1
    }, {
      "Key": "661",
      "Value": "Odessa-Midland TX",
      "CategoryId": 1
    }, {
      "Key": "662",
      "Value": "Lubbock TX",
      "CategoryId": 1
    }, {
      "Key": "663",
      "Value": "Scottsbluff NE-WY",
      "CategoryId": 1
    }, {
      "Key": "664",
      "Value": "Casper WY-ID-UT",
      "CategoryId": 1
    }, {
      "Key": "665",
      "Value": "Billings MT-WY",
      "CategoryId": 1
    }, {
      "Key": "666",
      "Value": "Great Falls MT",
      "CategoryId": 1
    }, {
      "Key": "667",
      "Value": "Missoula MT",
      "CategoryId": 1
    }, {
      "Key": "668",
      "Value": "Spokane WA-ID",
      "CategoryId": 1
    }, {
      "Key": "669",
      "Value": "Idaho Falls ID-WY",
      "CategoryId": 1
    }, {
      "Key": "670",
      "Value": "Twin Falls ID",
      "CategoryId": 1
    }, {
      "Key": "671",
      "Value": "Boise City ID-OR",
      "CategoryId": 1
    }, {
      "Key": "672",
      "Value": "Salt Lake City-Ogden UT-ID",
      "CategoryId": 1
    }, {
      "Key": "673",
      "Value": "Las Vegas NV-AZ-UT",
      "CategoryId": 1
    }, {
      "Key": "674",
      "Value": "Flagstaff AZ-UT",
      "CategoryId": 1
    }, {
      "Key": "675",
      "Value": "Farmington NM-CO",
      "CategoryId": 1
    }, {
      "Key": "676",
      "Value": "Albuquerque NM-AZ",
      "CategoryId": 1
    }, {
      "Key": "677",
      "Value": "El Paso TX-NM",
      "CategoryId": 1
    }, {
      "Key": "678",
      "Value": "Phoenix-Mesa AZ-NM",
      "CategoryId": 1
    }, {
      "Key": "679",
      "Value": "Tucson AZ",
      "CategoryId": 1
    }, {
      "Key": "680",
      "Value": "Bangor ME",
      "CategoryId": 1
    }, {
      "Key": "681",
      "Value": "Portland ME",
      "CategoryId": 1
    }, {
      "Key": "682",
      "Value": "Boston-Worcester MA-NH-RI-VT",
      "CategoryId": 1
    }, {
      "Key": "683",
      "Value": "Burlington VT-NY",
      "CategoryId": 1
    }, {
      "Key": "684",
      "Value": "Albany-Schenectady-Troy NY",
      "CategoryId": 1
    }, {
      "Key": "685",
      "Value": "Syracuse NY-PA",
      "CategoryId": 1
    }, {
      "Key": "686",
      "Value": "Rochester NY-PA",
      "CategoryId": 1
    }, {
      "Key": "687",
      "Value": "Buffalo-Niagara Falls NY-PA",
      "CategoryId": 1
    }, {
      "Key": "688",
      "Value": "State College PA",
      "CategoryId": 1
    }, {
      "Key": "689",
      "Value": "NYC-Long Is. NY-NJ-CT-PA-MA-VT",
      "CategoryId": 1
    }, {
      "Key": "690",
      "Value": "Harrisburg-Lebanon-Carlisle PA",
      "CategoryId": 1
    }, {
      "Key": "691",
      "Value": "Phil.-Atl. City PA-NJ-DE-MD",
      "CategoryId": 1
    }, {
      "Key": "692",
      "Value": "Wash.-Balt. DC-MD-VA-WV-PA",
      "CategoryId": 1
    }, {
      "Key": "693",
      "Value": "Salisbury MD-DE-VA",
      "CategoryId": 1
    }, {
      "Key": "694",
      "Value": "Jacksonville FL-GA",
      "CategoryId": 1
    }, {
      "Key": "695",
      "Value": "Orlando FL",
      "CategoryId": 1
    }, {
      "Key": "696",
      "Value": "Miami-Fort Lauderdale FL",
      "CategoryId": 1
    }, {
      "Key": "697",
      "Value": "Fort Myers-Cape Coral FL",
      "CategoryId": 1
    }, {
      "Key": "698",
      "Value": "Sarasota-Bradenton FL",
      "CategoryId": 1
    }, {
      "Key": "699",
      "Value": "Tampa-St. Petersburg FL",
      "CategoryId": 1
    }, {
      "Key": "700",
      "Value": "Tallahassee FL-GA",
      "CategoryId": 1
    }, {
      "Key": "701",
      "Value": "Dothan AL-FL-GA",
      "CategoryId": 1
    }, {
      "Key": "702",
      "Value": "Albany GA",
      "CategoryId": 1
    }, {
      "Key": "703",
      "Value": "Macon GA",
      "CategoryId": 1
    }, {
      "Key": "704",
      "Value": "Columbus GA-AL",
      "CategoryId": 1
    }, {
      "Key": "705",
      "Value": "Atlanta GA-AL-NC",
      "CategoryId": 1
    }, {
      "Key": "706",
      "Value": "Greenville-Spartanburg SC-NC",
      "CategoryId": 1
    }, {
      "Key": "707",
      "Value": "Asheville NC",
      "CategoryId": 1
    }, {
      "Key": "708",
      "Value": "Chattanooga TN-GA",
      "CategoryId": 1
    }, {
      "Key": "709",
      "Value": "Knoxville TN",
      "CategoryId": 1
    }, {
      "Key": "710",
      "Value": "Johnson City-Kingsport TN-VA",
      "CategoryId": 1
    }, {
      "Key": "711",
      "Value": "Hickory-Morganton NC-TN",
      "CategoryId": 1
    }, {
      "Key": "712",
      "Value": "Lexington KY-TN-VA-WV",
      "CategoryId": 1
    }, {
      "Key": "713",
      "Value": "Pittsburgh PA-WV",
      "CategoryId": 1
    }, {
      "Key": "714",
      "Value": "Erie PA",
      "CategoryId": 1
    }, {
      "Key": "715",
      "Value": "Hobbs NM-TX",
      "CategoryId": 1
    }, {
      "Key": "716",
      "Value": "Amarillo TX-NM",
      "CategoryId": 1
    }, {
      "Key": "717",
      "Value": "Santa Fe NM",
      "CategoryId": 1
    }, {
      "Key": "718",
      "Value": "Pueblo CO-NM",
      "CategoryId": 1
    }, {
      "Key": "719",
      "Value": "Denver-Boulder CO-KS-NE",
      "CategoryId": 1
    }, {
      "Key": "720",
      "Value": "Reno NV-CA",
      "CategoryId": 1
    }, {
      "Key": "721",
      "Value": "LA-Riverside-Orange Cnty CA-AZ",
      "CategoryId": 1
    }, {
      "Key": "722",
      "Value": "San Diego CA",
      "CategoryId": 1
    }, {
      "Key": "723",
      "Value": "Fresno CA",
      "CategoryId": 1
    }, {
      "Key": "724",
      "Value": "San Fran.-Oakland-San Jose CA",
      "CategoryId": 1
    }, {
      "Key": "725",
      "Value": "Sacramento-Yolo CA",
      "CategoryId": 1
    }, {
      "Key": "726",
      "Value": "Redding CA-OR",
      "CategoryId": 1
    }, {
      "Key": "727",
      "Value": "Eugene-Springfield OR-CA",
      "CategoryId": 1
    }, {
      "Key": "728",
      "Value": "Portland-Salem OR-WA",
      "CategoryId": 1
    }, {
      "Key": "729",
      "Value": "Pendleton OR-WA",
      "CategoryId": 1
    }, {
      "Key": "730",
      "Value": "Richland-Kennewick-Pasco WA",
      "CategoryId": 1
    }, {
      "Key": "731",
      "Value": "Seattle-Tacoma-Bremerton WA",
      "CategoryId": 1
    }, {
      "Key": "732",
      "Value": "Louisville KY-IN",
      "CategoryId": 1
    }, {
      "Key": "733",
      "Value": "Nashville TN-KY",
      "CategoryId": 1
    }, {
      "Key": "734",
      "Value": "Paducah KY-IL",
      "CategoryId": 1
    }, {
      "Key": "735",
      "Value": "Memphis TN-AR-MS-KY",
      "CategoryId": 1
    }, {
      "Key": "736",
      "Value": "Huntsville AL-TN",
      "CategoryId": 1
    }, {
      "Key": "737",
      "Value": "Tupelo MS-AL-TN",
      "CategoryId": 1
    }, {
      "Key": "738",
      "Value": "Greenville MS",
      "CategoryId": 1
    }, {
      "Key": "739",
      "Value": "Jackson MS-AL-LA",
      "CategoryId": 1
    }, {
      "Key": "740",
      "Value": "Birmingham AL",
      "CategoryId": 1
    }, {
      "Key": "741",
      "Value": "Montgomery AL",
      "CategoryId": 1
    }, {
      "Key": "742",
      "Value": "Mobile AL",
      "CategoryId": 1
    }, {
      "Key": "743",
      "Value": "Pensacola FL",
      "CategoryId": 1
    }, {
      "Key": "744",
      "Value": "Biloxi-Gulfport-Pascagoula MS",
      "CategoryId": 1
    }, {
      "Key": "745",
      "Value": "New Orleans LA-MS",
      "CategoryId": 1
    }, {
      "Key": "746",
      "Value": "Baton Rouge LA-MS",
      "CategoryId": 1
    }, {
      "Key": "747",
      "Value": "Lafayette LA",
      "CategoryId": 1
    }, {
      "Key": "748",
      "Value": "Lake Charles LA",
      "CategoryId": 1
    }, {
      "Key": "749",
      "Value": "Beaumont-Port Arthur TX",
      "CategoryId": 1
    }, {
      "Key": "750",
      "Value": "Shreveport-Bossier City LA-AR",
      "CategoryId": 1
    }, {
      "Key": "751",
      "Value": "Monroe LA",
      "CategoryId": 1
    }, {
      "Key": "752",
      "Value": "Little Rock AR",
      "CategoryId": 1
    }, {
      "Key": "753",
      "Value": "Fort Smith AR-OK",
      "CategoryId": 1
    }, {
      "Key": "754",
      "Value": "Fayetteville AR-MO-OK",
      "CategoryId": 1
    }, {
      "Key": "755",
      "Value": "Joplin MO-KS-OK",
      "CategoryId": 1
    }, {
      "Key": "756",
      "Value": "Springfield MO",
      "CategoryId": 1
    }, {
      "Key": "757",
      "Value": "Jonesboro AR-MO",
      "CategoryId": 1
    }, {
      "Key": "758",
      "Value": "St. Louis MO-IL",
      "CategoryId": 1
    }, {
      "Key": "759",
      "Value": "Springfield IL-MO",
      "CategoryId": 1
    }, {
      "Key": "760",
      "Value": "Columbia MO",
      "CategoryId": 1
    }, {
      "Key": "761",
      "Value": "Kansas City MO-KS",
      "CategoryId": 1
    }, {
      "Key": "762",
      "Value": "Des Moines IA-IL-MO",
      "CategoryId": 1
    }, {
      "Key": "763",
      "Value": "Peoria-Pekin IL",
      "CategoryId": 1
    }, {
      "Key": "764",
      "Value": "Davenport-Moline IA-IL",
      "CategoryId": 1
    }, {
      "Key": "765",
      "Value": "Cedar Rapids IA",
      "CategoryId": 1
    }, {
      "Key": "766",
      "Value": "Madison WI-IL-IA",
      "CategoryId": 1
    }, {
      "Key": "767",
      "Value": "La Crosse WI-MN",
      "CategoryId": 1
    }, {
      "Key": "768",
      "Value": "Rochester MN-IA-WI",
      "CategoryId": 1
    }, {
      "Key": "769",
      "Value": "Minneapolis-St. Paul MN-WI-IA",
      "CategoryId": 1
    }, {
      "Key": "770",
      "Value": "Wausau WI",
      "CategoryId": 1
    }, {
      "Key": "771",
      "Value": "Duluth-Superior MN-WI",
      "CategoryId": 1
    }, {
      "Key": "772",
      "Value": "Grand Forks ND-MN",
      "CategoryId": 1
    }, {
      "Key": "773",
      "Value": "Minot ND",
      "CategoryId": 1
    }, {
      "Key": "774",
      "Value": "Bismarck ND-MT-SD",
      "CategoryId": 1
    }, {
      "Key": "775",
      "Value": "Fargo-Moorhead ND-MN",
      "CategoryId": 1
    }, {
      "Key": "776",
      "Value": "Aberdeen SD",
      "CategoryId": 1
    }, {
      "Key": "777",
      "Value": "Rapid City SD-MT-NE-ND",
      "CategoryId": 1
    }, {
      "Key": "778",
      "Value": "Sioux Falls SD-IA-MN-NE",
      "CategoryId": 1
    }, {
      "Key": "779",
      "Value": "Sioux City IA-NE-SD",
      "CategoryId": 1
    }, {
      "Key": "780",
      "Value": "Omaha NE-IA-MO",
      "CategoryId": 1
    }, {
      "Key": "781",
      "Value": "Lincoln NE",
      "CategoryId": 1
    }, {
      "Key": "782",
      "Value": "Grand Island NE",
      "CategoryId": 1
    }, {
      "Key": "783",
      "Value": "North Platte NE-CO",
      "CategoryId": 1
    }, {
      "Key": "784",
      "Value": "Wichita KS-OK",
      "CategoryId": 1
    }, {
      "Key": "785",
      "Value": "Topeka KS",
      "CategoryId": 1
    }, {
      "Key": "786",
      "Value": "Anchorage AK",
      "CategoryId": 1
    }, {
      "Key": "787",
      "Value": "Honolulu HI",
      "CategoryId": 1
    }, {
      "Key": "788",
      "Value": "Guam",
      "CategoryId": 1
    }, {
      "Key": "789",
      "Value": "Puerto Rico-US Virgin Islands",
      "CategoryId": 1
    }, {
      "Key": "790",
      "Value": "American Samoa",
      "CategoryId": 1
    }, {
      "Key": "791",
      "Value": "Gulf of Mexico",
      "CategoryId": 1
    }]
  }, {
    "Id": 2,
    "Category": "Region",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "regionId",
    "Values": [{
      "Key": "601",
      "Value": "Southeast",
      "CategoryId": 2
    }, {
      "Key": "602",
      "Value": "Great Lakes",
      "CategoryId": 2
    }, {
      "Key": "603",
      "Value": "Mountain",
      "CategoryId": 2
    }, {
      "Key": "604",
      "Value": "Plains",
      "CategoryId": 2
    }, {
      "Key": "605",
      "Value": "Northeast",
      "CategoryId": 2
    }, {
      "Key": "607",
      "Value": "Pacific",
      "CategoryId": 2
    }, {
      "Key": "608",
      "Value": "Mid-Atlantic",
      "CategoryId": 2
    }, {
      "Key": "3255",
      "Value": "South Central",
      "CategoryId": 2
    }]
  }, {
    "Id": 3,
    "Category": "Tower Owner",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "towerOwnerId",
    "Values": [{
      "Key": "3547",
      "Value": "Not Specified",
      "CategoryId": 3
    }, {
      "Key": "4326",
      "Value": "Crown Castle",
      "CategoryId": 3
    }, {
      "Key": "5032",
      "Value": "American Tower",
      "CategoryId": 3
    }, {
      "Key": "5033",
      "Value": "APC",
      "CategoryId": 3
    }, {
      "Key": "5034",
      "Value": "Branch",
      "CategoryId": 3
    }, {
      "Key": "5036",
      "Value": "Echo Properties",
      "CategoryId": 3
    }, {
      "Key": "5037",
      "Value": "Horvath",
      "CategoryId": 3
    }, {
      "Key": "5039",
      "Value": "Island Tower",
      "CategoryId": 3
    }, {
      "Key": "5040",
      "Value": "Lend Lease",
      "CategoryId": 3
    }, {
      "Key": "5041",
      "Value": "Melody",
      "CategoryId": 3
    }, {
      "Key": "5042",
      "Value": "PDS Wireless",
      "CategoryId": 3
    }, {
      "Key": "5043",
      "Value": "SBA",
      "CategoryId": 3
    }, {
      "Key": "5044",
      "Value": "Skyway",
      "CategoryId": 3
    }, {
      "Key": "5045",
      "Value": "Tarpon",
      "CategoryId": 3
    }, {
      "Key": "5046",
      "Value": "Towerco",
      "CategoryId": 3
    }, {
      "Key": "5047",
      "Value": "TransAmerica",
      "CategoryId": 3
    }, {
      "Key": "5048",
      "Value": "Vertical Bridge",
      "CategoryId": 3
    }, {
      "Key": "5051",
      "Value": "Bluesky",
      "CategoryId": 3
    }, {
      "Key": "5740",
      "Value": "Industrial Communications, LLC",
      "CategoryId": 3
    }, {
      "Key": "5782",
      "Value": "US Cellular",
      "CategoryId": 3
    }, {
      "Key": "6815",
      "Value": "KGI",
      "CategoryId": 3
    }, {
      "Key": "6827",
      "Value": "Airwave",
      "CategoryId": 3
    }, {
      "Key": "8543",
      "Value": "Repeater Communications Group",
      "CategoryId": 3
    }, {
      "Key": "9669",
      "Value": "ITE",
      "CategoryId": 3
    }, {
      "Key": "9670",
      "Value": "Commnet",
      "CategoryId": 3
    }]
  }, {
    "Id": 4,
    "Category": "Tower Type",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "towerTypeId",
    "Values": [{
      "Key": "10401",
      "Value": "Apartment",
      "CategoryId": 4
    }, {
      "Key": "10402",
      "Value": "Condominium",
      "CategoryId": 4
    }, {
      "Key": "10403",
      "Value": "Guyed",
      "CategoryId": 4
    }, {
      "Key": "10404",
      "Value": "Guyed Tower",
      "CategoryId": 4
    }, {
      "Key": "10405",
      "Value": "Hotel",
      "CategoryId": 4
    }, {
      "Key": "10406",
      "Value": "Mixed-use",
      "CategoryId": 4
    }, {
      "Key": "10407",
      "Value": "Monopine",
      "CategoryId": 4
    }, {
      "Key": "10408",
      "Value": "Monopole",
      "CategoryId": 4
    }, {
      "Key": "10409",
      "Value": "Monopole Tree",
      "CategoryId": 4
    }, {
      "Key": "10410",
      "Value": "Office Building",
      "CategoryId": 4
    }, {
      "Key": "10411",
      "Value": "Retail Building",
      "CategoryId": 4
    }, {
      "Key": "10412",
      "Value": "Rooftop",
      "CategoryId": 4
    }, {
      "Key": "10413",
      "Value": "Self Support",
      "CategoryId": 4
    }, {
      "Key": "10414",
      "Value": "SST",
      "CategoryId": 4
    }, {
      "Key": "10415",
      "Value": "SST On Rooftop",
      "CategoryId": 4
    }, {
      "Key": "10416",
      "Value": "Stealth Pole",
      "CategoryId": 4
    }, {
      "Key": "10417",
      "Value": "TBD",
      "CategoryId": 4
    }, {
      "Key": "10418",
      "Value": "Tower On Rooftop",
      "CategoryId": 4
    }, {
      "Key": "10419",
      "Value": "Water Tower",
      "CategoryId": 4
    }, {
      "Key": "10420",
      "Value": "Not Specified",
      "CategoryId": 4
    }, {
      "Key": "10442",
      "Value": "Others",
      "CategoryId": 4
    }, {
      "Key": "10446",
      "Value": "Building",
      "CategoryId": 4
    }, {
      "Key": "10447",
      "Value": "WaterTank",
      "CategoryId": 4
    }]
  }, {
    "Id": 5,
    "Category": "SA/A&E Vendor",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "sAAEVendorId",
    "Values": [{
      "Key": "1396",
      "Value": "FDH",
      "CategoryId": 5
    }, {
      "Key": "1398",
      "Value": "Centerline C",
      "CategoryId": 5
    }, {
      "Key": "1399",
      "Value": "PM&A",
      "CategoryId": 5
    }, {
      "Key": "1401",
      "Value": "Dish",
      "CategoryId": 5
    }, {
      "Key": "1402",
      "Value": "MD7",
      "CategoryId": 5
    }, {
      "Key": "3547",
      "Value": "Not Specified",
      "CategoryId": 5
    }, {
      "Key": "3606",
      "Value": "Selective Site Consultants, Inc.",
      "CategoryId": 5
    }, {
      "Key": "4199",
      "Value": "Infinigy Solutions, L.L.C. (aka Core)",
      "CategoryId": 5
    }, {
      "Key": "4200",
      "Value": "Dan Combs Consulting, Inc.",
      "CategoryId": 5
    }, {
      "Key": "4204",
      "Value": "TEP OPCO, LLC",
      "CategoryId": 5
    }, {
      "Key": "4326",
      "Value": "Crown Castle",
      "CategoryId": 5
    }, {
      "Key": "5032",
      "Value": "American Tower",
      "CategoryId": 5
    }, {
      "Key": "5043",
      "Value": "SBA",
      "CategoryId": 5
    }, {
      "Key": "6821",
      "Value": "Centerline Solutions",
      "CategoryId": 5
    }, {
      "Key": "6822",
      "Value": "NB&C",
      "CategoryId": 5
    }]
  }, {
    "Id": 6,
    "Category": "OEM",
    "MaxSelections": 10,
    "MinSelections": 0,
    "ESColumnName": "oEMVendorId",
    "Values": [{
      "Key": "3547",
      "Value": "Not Specified",
      "CategoryId": 6
    }, {
      "Key": "3601",
      "Value": "Ericsson",
      "CategoryId": 6
    }, {
      "Key": "3603",
      "Value": "Nokia",
      "CategoryId": 6
    }]
  }];

const output = input.reduce((accu, {Values, ...rest}) => {
    const values = Values.filter(({Value}) => Value.includes('Rich'));
    if(values.length > 0) {
        accu.push({...rest, Values: values})
    }
    return accu;
}, []);

console.log(output);