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 partial class Welcome
public Datum[] Data { get; set; }
[JsonProperty("has_more")]
public bool HasMore { get; set; }
[JsonProperty("total_results")]
public long TotalResults { get; set; }
public partial class Datum
[JsonProperty("addresses")]
public object[] Addresses { get; set; }
[JsonProperty("contacts")]
public Contact[] Contacts { get; set; }
[JsonProperty("created_by")]
public string CreatedBy { get; set; }
[JsonProperty("created_by_name")]
public string CreatedByName { get; set; }
public Custom Custom { get; set; }
[JsonProperty("custom.lcf_dDtwGb41tpi8XkVMMgxdHxEJ92A7ujreRU1aPPZd95B")]
public string CustomInitialService { get; set; }
[JsonProperty("custom.lcf_fUNjcSq8bemwdQL0wogc3wgyxmz3ZD17fKdv8s4wkWV")]
public string CustomLeadOwner { get; set; }
[JsonProperty("custom.lcf_UfNWMxg2f7UU28rI9RAhTEAPWMyXU1UFZb5oNJEgR0K")]
public string CustomMarketingSource { get; set; }
[JsonProperty("custom.lcf_y37bo72LesrOBWuVPSoRfIazw5KflujnV81nGCfcjZ3")]
public string CustomDateCreated { get; set; }
[JsonProperty("date_created")]
public string DateCreated { get; set; }
[JsonProperty("date_updated")]
public string DateUpdated { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("display_name")]
public string DisplayName { get; set; }
[JsonProperty("html_url")]
public string HtmlUrl { get; set; }
public string Id { get; set; }
[JsonProperty("integration_links")]
public IntegrationLink[] IntegrationLinks { get; set; }
public string Name { get; set; }
[JsonProperty("opportunities")]
public Opportunity[] Opportunities { get; set; }
[JsonProperty("organization_id")]
public string OrganizationId { get; set; }
[JsonProperty("status_id")]
public string StatusId { get; set; }
[JsonProperty("status_label")]
public string StatusLabel { get; set; }
public object[] Tasks { get; set; }
[JsonProperty("updated_by")]
public string UpdatedBy { get; set; }
[JsonProperty("updated_by_name")]
public string UpdatedByName { get; set; }
public object Url { get; set; }
public partial class Opportunity
[JsonProperty("confidence")]
public long Confidence { get; set; }
[JsonProperty("contact_id")]
public object ContactId { get; set; }
[JsonProperty("contact_name")]
public object ContactName { get; set; }
[JsonProperty("created_by")]
public string CreatedBy { get; set; }
[JsonProperty("created_by_name")]
public string CreatedByName { get; set; }
[JsonProperty("date_created")]
public string DateCreated { get; set; }
[JsonProperty("date_lost")]
public object DateLost { get; set; }
[JsonProperty("date_updated")]
public string DateUpdated { get; set; }
[JsonProperty("date_won")]
public object DateWon { get; set; }
public string Id { get; set; }
[JsonProperty("integration_links")]
public object[] IntegrationLinks { get; set; }
[JsonProperty("lead_id")]
public string LeadId { get; set; }
[JsonProperty("lead_name")]
public string LeadName { get; set; }
public string Note { get; set; }
[JsonProperty("organization_id")]
public string OrganizationId { get; set; }
[JsonProperty("status_id")]
public string StatusId { get; set; }
[JsonProperty("status_label")]
public string StatusLabel { get; set; }
[JsonProperty("status_type")]
public string StatusType { get; set; }
[JsonProperty("updated_by")]
public string UpdatedBy { get; set; }
[JsonProperty("updated_by_name")]
public string UpdatedByName { get; set; }
[JsonProperty("user_id")]
public string UserId { get; set; }
[JsonProperty("user_name")]
public string UserName { get; set; }
public long Value { get; set; }
[JsonProperty("value_currency")]
public string ValueCurrency { get; set; }
[JsonProperty("value_formatted")]
public string ValueFormatted { get; set; }
[JsonProperty("value_period")]
public string ValuePeriod { get; set; }
public partial class Custom
[JsonProperty("Date Created")]
public string DateCreated { get; set; }
[JsonProperty("Initial Service")]
public string InitialService { get; set; }
[JsonProperty("Lead Owner")]
public string LeadOwner { get; set; }
[JsonProperty("Marketing Source")]
public string MarketingSource { get; set; }
public partial class Contact
[JsonProperty("created_by")]
public string CreatedBy { get; set; }
[JsonProperty("date_created")]
public string DateCreated { get; set; }
[JsonProperty("date_updated")]
public string DateUpdated { get; set; }
public Email[] Emails { get; set; }
public string Id { get; set; }
[JsonProperty("integration_links")]
public IntegrationLink[] IntegrationLinks { get; set; }
[JsonProperty("lead_id")]
public string LeadId { get; set; }
public string Name { get; set; }
[JsonProperty("organization_id")]
public string OrganizationId { get; set; }
public Phone[] Phones { get; set; }
public string Title { get; set; }
[JsonProperty("updated_by")]
public string UpdatedBy { get; set; }
public object[] Urls { get; set; }
public partial class Phone
[JsonProperty("phone_formatted")]
public string PhoneFormatted { get; set; }
public string PurplePhone { get; set; }
public string Type { get; set; }
public string EmailValue { get; set; }
public string Type { get; set; }
public partial class IntegrationLink
public string Name { get; set; }
public string Url { get; set; }
public partial class Welcome
public static class Serialize
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
public static void Test()
var json = JsonConvert.DeserializeObject<Welcome>(html);
.SelectMany(d => d.Contacts)
.SelectMany(c => c.Emails)
.Select(e => e.EmailValue)
.SelectMany(d => d.Contacts)
.SelectMany(c => c.Phones)
.Select(p => p.PurplePhone)
Console.WriteLine("Emails: {0}", JsonConvert.SerializeObject(emails));
Console.WriteLine("Phones: {0}", JsonConvert.SerializeObject(phones));
""created_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""date_created"": ""2017-12-03T05:42:30.737000+00:00"",
""date_updated"": ""2017-12-03T05:45:32.227000+00:00"",
""email"": ""testemail@testemail.com"",
""id"": ""cont_kH9tcx970T3ZTGKPPP2vh5u3Ha8P9Rjz6gGqflgzwvy"",
""name"": ""LinkedIn Search"",
""url"": ""https://www.linkedin.com/search/results/index/?keywords=Test%20Woodard""
""lead_id"": ""lead_12Rz7R2TrWmwUhCGVTRh8rt6A8hokaXgujSEPlfoWpD"",
""organization_id"": ""orga_iFnIMLDbvGevDrXMHYQSbYnLu1GjrdM2TEWWsCoraJH"",
""phone"": ""+15558675309"",
""phone_formatted"": ""+1 555-867-5309"",
""updated_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""created_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""created_by_name"": ""Test User"",
""Date Created"": ""2017-12-03"",
""Initial Service"": ""Men's Health"",
""Lead Owner"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""Marketing Source"": ""Bing""
""custom.lcf_UfNWMxg2f7UU28rI9RAhTEAPWMyXU1UFZb5oNJEgR0K"": ""Bing"",
""custom.lcf_dDtwGb41tpi8XkVMMgxdHxEJ92A7ujreRU1aPPZd95B"": ""Chiropractor"",
""custom.lcf_fUNjcSq8bemwdQL0wogc3wgyxmz3ZD17fKdv8s4wkWV"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""custom.lcf_y37bo72LesrOBWuVPSoRfIazw5KflujnV81nGCfcjZ3"": ""2017-12-03"",
""date_created"": ""2017-12-03T05:42:30.733000+00:00"",
""date_updated"": ""2017-12-03T05:45:32.234000+00:00"",
""display_name"": ""test"",
""html_url"": ""https://app.close.io/lead/lead_12Rz7R2TrWmwUhCFVTRh8rt6A8hokaXgujSEPlfoWpG/"",
""id"": ""lead_12Rz7R2TrWmwUhCFVTRh8rt6A8hokaXgujSEPlfoWpD"",
""name"": ""Google Search"",
""url"": ""http://google.com/search?q=test""
""created_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""created_by_name"": ""Test User"",
""date_created"": ""2017-12-03T05:44:31.131000+00:00"",
""date_updated"": ""2017-12-03T05:44:31.131000+00:00"",
""id"": ""oppo_xQ5S1dHMjDWoeUBAigtyiwuwFUkxtbxHURQX5UaL7fT"",
""integration_links"": [],
""lead_id"": ""lead_12Rz7R2TrWmwUhCFVTRh8rt6A8hokaXgujSEPlfoWpD"",
""organization_id"": ""orga_iFnIMLDbvNevDrXMHYQSbYnLu1GjrdM2TEWWsCoraJH"",
""status_id"": ""stat_SwQmzqoIqIt20j9YBDxIYem11GyZPGL30G7PdkWYdvG"",
""status_label"": ""Chiropractor"",
""status_type"": ""active"",
""updated_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""updated_by_name"": ""Test User"",
""user_id"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""user_name"": ""Test User"",
""value_currency"": ""USD"",
""value_formatted"": ""$1,400"",
""value_period"": ""one_time""
""organization_id"": ""orga_iFnIMLDbvNevDrXMHYQSbYnLu1GjrdM2TEWWsCoraJH"",
""status_id"": ""stat_auhCEJZNhaUnX9DHdrCaZ5r5mhpqxjfaE1hdwnPz6xx"",
""status_label"": ""Potential"",
""updated_by"": ""user_C8ptFaOBRGnsYadWFUZCRCYXRnuV5Ch8Lgr9LKXz7zG"",
""updated_by_name"": ""Test User"",
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");