C# - Convert List<JToken> to List<string> one-liner

Viewed 7939

I got a Json response from a API which contains a JArray in which there is a JProperty named "title".

I have a working one-liner which returns a List<JToken> which stores all the "title" properties of the Json:

List<JToken> queryResult = JObject
                    .Parse(client.DownloadString(url))["results"]
                    .Children()["title"]
                    .ToList();

I tried to edit the above one-liner so it returns a List<string> but without success...

Is there a way to keep it as a one-liner?

1 Answers

A bit too late, but if someone requires.

List<string> stringList = queryResult.Values<string>().ToList();

may do the job.

Related