I have been unable to parse
{
"Group":[
{
"Rssfeed":[
{
"id":"1",
"rname":"jamaica Gleaner",
"rurl":"http:\/\/jamaica-gleaner.com\/feed\/rss.xml"
},
{
"id":"2",
"rname":"Jamaica Observer News",
"rurl":"http:\/\/www.jamaicaobserver.com\/rss\/business\/"
},
{
"id":"3",
"rname":"Jamaica Observer Sports ",
"rurl":"http:\/\/www.jamaicaobserver.com\/rss\/sport\/"
},
{
"id":"4",
"rname":"Jamaica-Gleaner News Feed",
"rurl":"http:\/\/jamaica-gleaner.com\/feed\/news.xml"
},
{
"id":"5",
"rname":"Jamaica-Gleaner Sports",
"rurl":"http:\/\/jamaica-gleaner.com\/feed\/sports.xml"
}
]
}
]
}
As I keep getting nullreferenceexception when trying to run the following code:
JObject jo = JObject.Parse(json);
JArray jar = (JArray)jo["Group"][0]["RssFeed"];
//loop this
foreach (JObject o in jar.Children<JObject>())
{
foreach (JProperty p in o.Properties())
{
string name = p.Name;
string value = p.Value.ToString();
MessageBox.Show(name);
}
}
If I remove the [0]["RssFeed"] from the JArray I get no a messagebox with RssFeed string, but I am not sure I see why it doesn't work with the full code, is there a better approach to this problem? I am using json.net for the first time so maybe I am over looking a few details. Thanks for your attention.