控制台
JArray array = new JArray(); var obj = new {Id=1,Name="lucy" }; array.Add(obj); Console.WriteLine(array); Console.ReadKey();
控制台运行提示:Could not determine JSON object type for type 错误
解决问题的办法也很简单~
用JToken.FromObject即可
代码如下
JArray array = new JArray();
var obj = new {Id=1,Name="lucy" };
array.Add(JToken.FromObject(obj));//此处更改,
Console.WriteLine(array);
Console.ReadKey();