using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public string ExternalRateId { get; set; }
public string ExternalRateCardId { get; set; }
public List<Rate> Rates { get; set; }
public bool IsUpdate { get; set; }
public List<RateCard> RateCards { get; set; }
public static void Test()
var root = JsonConvert.DeserializeObject<Root>(json);
var externalRateIds = root.RateCards.SelectMany(r => r.Rates).Select(r => r.ExternalRateId).ToArray();
Console.WriteLine(JsonConvert.SerializeObject(externalRateIds));
static string GetJson() =>@"{
""ExternalRateCardId"": ""62283ab4"",
""ExternalRateId"": ""2a77db10"",
""ExternalRateCardId"": ""f6878b23"",
""ExternalRateId"": ""2a739550"",
""ExternalRateCardId"": ""3f51162c"",
""ExternalRateId"": ""2a751bf0"",
public static void Main()
Console.WriteLine("Environment version: {0} ({1}), {2}", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , Environment.Version, Environment.OSVersion);
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Namespace, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");