using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static void Main()
static void TraverseAndRemove()
var keys = new string[] { "a", "b", "c", "e" };
var root = JObject.Parse(json);
var descendants = root.DescendantsAndSelf().ToList();
foreach (var d in descendants)
var jProp = d as JProperty;
if (jProp != null && !keys.Contains(jProp.Name))
Console.WriteLine(JsonConvert.SerializeObject(root, Formatting.Indented).ToString());