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 static void Test()
var jObject = JObject.Parse(GetJson());
foreach (var category in jObject["Categories"].OfType<JObject>())
var result = category.Count == 1 && category.Property("Name") != null;
Console.WriteLine("Result for Category \"{0}\" = {1}:", category["Name"], result);
Console.WriteLine(" " + category.ToString(Formatting.None));
Assert.IsTrue(count == 4, string.Format("Wrong number of objects {0} selected!", count));
""Name"": ""ThirdParty"",
{ ""Name"": ""Identity"" },
""Name"": ""Contact Information"",
{ ""Name"": ""Phones"" },
{ ""Name"": ""Addresses"" },
{ ""Name"": ""Bank Accounts"" },
{ ""No Name"": ""this object has no Name property and so should have been filtered out"" },
{ ""Name"": ""Test data"" },
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: ");