Casey Crookston Casey Crookston - 3 years ago 247
C# Question

remove pre-pending "data" from json string

I am making a call to a third party API, and the json string I get back looks like this:


And then I have a class

private class FoorBarURLs
public int id { get; set; }
public string name { get; set; }
public string url { get; set; }

So, I don't care about the
or the
or the
. All I need is the data inside

Given that what I'm starting with is just a string, how do I extract that list from
so I can do this:

List<FoorBarURLs> myList = JsonConvert.DeserializeObject<List<FoorBarURLs>>(???)

Answer Source

Use a temporary JObject

var obj = JObject.Parse(json)["data"].ToObject<List<FoorBarURLs>>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download