Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从这个 Response计算对象的数量。我不想为这么小的目的制作课程,然后对课程进行迭代。有没有更短的方法来做到这一点。
我同时使用 JSON.NET 和 web.Serialization。
这将返回数组中直接对象的计数。
var input = "[{Name: 'Hello'}, {Name: 'Hi'}]"; dynamic response = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<dynamic>(input); Response.Write(response.Length);