using System.Collections.Generic;
using Newtonsoft.Json.Linq;
""Institution"": { ""Name"" : """", ""Id"" : """" },
""PreferredContactMethod"": """",
""Status"" : { ""Name"" : """", ""Id"" : """" },
""FullNameWithEmail"": """",
""LastFirstEmail"" : """",
""PhysicalAddressString"": """",
""PhoneNumberFormatted"" : """",
""RegionSubRegion"" : { ""Name"" : """", ""Id"" : """" },
""FullNameWithEmail"": """",
""LastFirstEmail"" : """",
""PhysicalAddressString"": """",
""PhoneNumberFormatted"" : """"
""ServiceCoordinator"": {
""FullNameWithEmail"": """",
""LastFirstEmail"" : """",
""PhysicalAddressString"": """",
""PhoneNumberFormatted"" : """"
JObject jsonObject = JObject.Parse(json);
int maxDepth = CalculateJsonMaxDepth(jsonObject);
Console.WriteLine("Max Depth: " + maxDepth);
private static int CalculateJsonMaxDepth(JToken token)
if (token == null || !token.HasValues)
foreach (var child in token.Children())
int childDepth = CalculateJsonMaxDepth(child);
if (childDepth + 1 > maxDepth)
maxDepth = childDepth + 1;