using System.Collections.Generic;
public string Name { get; set; }
public string Color { get; set; }
public int Min { get; set; }
public int Max { get; set; }
public string Color { get; set; }
public int Size { get; set; }
public List<Person> People { get; set; }
public List<Item> Items { get; set; }
{ ""name"": ""Mary"", ""color"": ""green"", ""min"": 1, ""max"": 5 },
{ ""name"": ""John"", ""color"": ""red"", ""min"": 2, ""max"": 6 }
{ ""color"": ""green"", ""size"": 5 },
{ ""color"": ""red"", ""size"": 3 },
{ ""color"": ""blue"", ""size"": 4 }
var options = new JsonSerializerOptions
PropertyNameCaseInsensitive = true
Data data = JsonSerializer.Deserialize<Data>(json, options);
if (data == null || data.People == null || data.Items == null)
Console.WriteLine("Error: JSON data is null or invalid.");
int totalItems = data.Items.Count;
Dictionary<string, int> matchedCounts = new Dictionary<string, int>();
foreach (var person in data.People)
matchedCounts[person.Name] = 0;
foreach (var item in data.Items)
foreach (var person in data.People)
if (item.Color == person.Color && item.Size >= person.Min && item.Size <= person.Max)
matchedCounts[person.Name]++;
Console.WriteLine($"Total items: {totalItems}");
Console.WriteLine($"Total unmatched items: {unmatchedItems}");
foreach (var match in matchedCounts)
Console.WriteLine($"Items matched by {match.Key}: {match.Value}");
Console.WriteLine($"Error parsing JSON: {ex.Message}");