I am trying to create or searealize json in this format
{
"title": "Star Wars",
"link": "http://www.starwars.com",
"description": "Star Wars blog.",
"item": [
{
"title": "Episode VII",
"description": "Episode VII production",
"link": "episode-vii-production.aspx"
},
{
"title": "Episode VITI",
"description": "Episode VII production",
"link": "episode-vii-production.aspx"
}
]
}
i am trying this achieve this
dynamic o = new ExpandoObject();
o.title= "fdsfs";
o.link= "fsrg";
o.description="fdsfs";
foreach (var adata in all)
{
o.item.title="fgfd";
o.item.description="sample desc";
o.item.link="http://google.com"
}
string json = JsonConvert.SerializeObject(o);
but than here it throws exception on foreach loop on item it tells it does not contain defination for the same etc .so what i am doing wrong and how to achieve the same