Reputation: 1709
I'm using Json.net for a project and I need to get specific items (in that case "episode_key") from an JArray. I use that way to do so, but I'm wondering if there is another way (slighter) :
foo is a JArray which a geted from : var foo = data["foo"];
for (int i=0; i < foo.Count(); i++)
{
TvProgram prog = new TvProgram { Key = foo[i]["episode_key"].ToString() }; // set the episode key
}
My json object look's like :
foo: [
{
episode_key: "32",
ddr_timeframes: [],
keywords: "",
synopsis: ""
},
{
episode_key: "542",
keywords: "",
synopsis: ""
}]
Regards.
Upvotes: 0
Views: 1001
Reputation: 1709
I found a way to do so with linq :
var keys = from m in foo
select m["episode_key"];
Regards
Upvotes: 2