I am using Angular JS to create JSON from MVC Controller to View. I passed it previously like this Model
public class obj
{
public string somestring {get;set;}
}
MVC controller
List<obj> lstObj=new List<obj>();
obj o = new obj();
o.somestring="somestring";
lstObj.Add(o);
IDictionary<string,object> dic=new Dictionary<string,object>();
dic.Add("data",lstObj);
return Json(dic);
in the view I get the Json as
{["somestring":"somestring"]}
But when I try the same code with ExpandoObject from this answer to Dynamically Add C# Properties at Runtime
List<dynamic> lstObj = new List<dynamic>();
var dynO = DataHelper.GetDynamicObject(new Dictionary<string, object>()
{
{"somestring","somestring"}
});
lstObj.Add(dynO);
IDictionary<string,object> dic=new Dictionary<string,object>();
dic.Add("data",lstObj);
return Json(dic);
it returns
{[]}
Is it feasible to obtain Json using ExpandoObject? Thanks in advance