如何在C#应用程序中导入JsonConvert?
我创build了一个C#库项目。 该项目在一个class级有这样的线路:
JsonConvert.SerializeObject(objectList); 我得到错误说
当前上下文中不存在名称JsonConvert。
 为了解决这个问题,我添加了System.ServiceModel.Web.dll到引用,但没有运气。 我怎样才能解决这个错误? 
  JsonConvert来自命名空间Newtonsoft.Json ,而不是System.ServiceModel.Web 
 使用NuGet下载package 
“项目” – >“pipe理NuGet包” – >“search”newtonsoft json“ – >点击”安装“。
 右键单击该项目,然后selectManage NuGet Packages..在这个selectJson.NET并安装 
安装后,
使用下面的命名空间
 using Newtonsoft.Json; 
然后使用以下来反序列化
 JsonConvert.DeserializeObject 
使用NuGet安装它:
 Install-Package Newtonsoft.Json 
发表这个答案。
或者如果你使用的是dotnet Core,
添加到您的.csproj文件
  <ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> </ItemGroup> 
和
 dotnet restore 
工具 – > NuGet程序包pipe理器 – >程序包pipe理器控制台
 PM> Install-Package Newtonsoft.Json