我构建了一个 ASP.NET Web Api。现在,我已将项目更新为 MVC 4 RC,但动态对象不再按预期工作。
我有这个:
var Arr = new JsonArray();
foreach (var Post in Coll)
{
dynamic Item = new JsonObject();
Item.Header = Post.Header;
Item.Body = Post.Body;
Item.Language = Post.Language;
Arr.Add(Item);
}
return Request.CreateResponse(HttpStatusCode.OK, Arr);
我从中得到的结果是(在浏览器中):
[{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]},{"Header":[],"Body":[],"Language":[]}]
在调试中我得到这个:(对象Arr)
{[{"Header":"All distances","Body":"All distances are ","Language":"EN"},{"Header":...
为什么不一样?
(Col 是一个对象列表)