如何在C#应用程序中导入JsonConvert? [英] How to import JsonConvert in C# application?

查看:65
本文介绍了如何在C#应用程序中导入JsonConvert?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个C#库项目.该项目将这一行归为一类:

I created a C# library project. The project has this line in one class:

JsonConvert.SerializeObject(objectList);

我说错了

名称JsonConvert在当前上下文中不存在.

the name JsonConvert doesn't exist in the current context.

要解决此问题,我在引用中添加了System.ServiceModel.Web.dll,但没有运气.我该如何解决这个错误?

To fix that, I added System.ServiceModel.Web.dll to references but had no luck. How can I solve this error?

推荐答案

JsonConvert来自命名空间Newtonsoft.Json,而不是System.ServiceModel.Web

JsonConvert is from the namespace Newtonsoft.Json, not System.ServiceModel.Web

使用NuGet下载package

项目"->管理NuGet软件包"->搜索"newtonsoft json".->单击安装".

"Project" -> "Manage NuGet packages" -> "Search for "newtonsoft json". -> click "install".

这篇关于如何在C#应用程序中导入JsonConvert?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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