如何在ASP.NET 5中使用JavaScriptSerializer? [英] How do I use JavaScriptSerializer in ASP.NET 5?
问题描述
我正在将项目移植到 DNX-Core 5.0
并尝试开始工作,但找不到 JavaScriptSerializer
和 AppSettingReader
类。我知道 System.Web
已删除,所以请有人帮助我找到使用它们的替代方法。
I am porting my project to DNX-Core 5.0
and trying to get work but I cannot find the JavaScriptSerializer
and AppSettingReader
classes. I know the System.Web
is removed and so please anyone help me to find the alternative of using them.
推荐答案
ASP.Net 5团队放弃了 JavaScriptSerializer
支持广泛使用的 Newtonsoft.Json
包,但它们确实提供了JsonInputFormatter 与MVC配合使用,以便能够更直接地返回对象。
The ASP.Net 5 team dropped the JavaScriptSerializer
in favor of the widely used Newtonsoft.Json
package, but they did provide a JsonOutputFormatter and a JsonInputFormatter for use with MVC to be able to return objects more directly.
对于 AppSettingReader
,您需要查看新的 ASP.Net 5配置模型。 很少博客发布。这些帖子仅详细介绍了如何加载各个字段,但是选项模型中的测试表明,您可以直接绑定到对象。
For the AppSettingReader
you'll want to look at the new ASP.Net 5 Configuration Model. This has been detailed in a few blog posts while it's being built. These posts only detail how to load out individual fields, but the tests in the Options Model show that you can bind directly to an object.
这篇关于如何在ASP.NET 5中使用JavaScriptSerializer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!