如何在 ASP.NET 5 中使用 JavaScriptSerializer? [英] How do I use JavaScriptSerializer in ASP.NET 5?

查看:54
本文介绍了如何在 ASP.NET 5 中使用 JavaScriptSerializer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的项目移植到 DNX-Core 5.0 并尝试开始工作,但我找不到 JavaScriptSerializerAppSettingReader 类.我知道 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.

是否有任何 Nuget 可用于包含它们?

Is there any Nuget available to include them?

推荐答案

ASP.Net 5 团队放弃了 JavaScriptSerializer,转而支持广泛使用的 Newtonsoft.Json 包,但他们确实提供了一个 JsonOutputFormatter 和用于 MVC 的 JsonInputFormatter能够更直接地返回对象.

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 配置模型.这已在少数博客posts 正在构建中.这些帖子仅详细说明如何加载单个字段,但 选项模型 中的测试表明您可以直接绑定到一个对象.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆