Trying to make a xml from a json string
var serializer = new JavaScriptSerializer();
var json1 = "[count:{first:1,second:2,third:3},{first:11,second:22,third:33}]";
var jsons = serializer.Serialize(json1);
dynamic jsona = serializer.Deserialize(json1, typeof(object));
var xmld = new XDocument(new XElement("count", jsona.Select(c =>
new XElement("first", (string)c["first"]),
new XElement("second", (string)c["second"]),
new XElement("third", (string)c["third"]))
)
);
Error Message:
Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
What I have tried:
I have made sure that here is one "new XElement" for each element. The error iswith "c". Also, serializer.Serialize() is returning "[object,Object],[object,Object]". I am hoping it is like Javascript JSON.stringify().