Using JObject and JProperty with JSON.Net 4.0
There are many ways you can do that, and what you have is fine. A few other alternatives are shown below:
- Get the first element of the array, instead of all the children
Use
SelectToken
to go to the first array element with a single callstring json = @"{ ""data"": [ { ""installed"": 1, ""user_likes"": 1, ""user_education_history"": 1, ""friends_education_history"": 1, ""bookmarked"": 1 } ] }"; JObject j = JObject.Parse(json); // Directly traversing the graph var lst = j["data"][0].Select(jp => ((JProperty)jp).Name).ToList(); Console.WriteLine(string.Join("--", lst)); // Using SelectToken lst = j.SelectToken("data[0]").Children<JProperty>().Select(p => p.Name).ToList(); Console.WriteLine(string.Join("--", lst));