命名空间'System'中不存在'Json'的类型或命名空间名称(是否缺少程序集引用?



我正在使用.NET Framework 4.5,但我遇到了这个问题。 The type or namespace 'Json' does not exist in the namespace 'System'

我试图Install-Package System.Json -Version 4.0.20126.16343但后来我遇到了这个问题。

The type 'System.Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

来源: https://www.nuget.org/packages/System.Json

任何想法将不胜感激!

该软件包已停产,不应再使用。

如果您有控制台应用程序,我可以推荐两个选项:

  • JSON.NET。不是.NET Framework本身的一部分,但比Microsoft的实现快得多;
  • 微软实现JavaScriptSerializer .

两者都能够读取和写入 JSON。我发现 JSON.NET 库更易于使用,功能更完整。

>using Newtonsoft.Json;应该完成工作。

现在您可以使用:

JsonConvert.SerializeObject
JsonConvert.DeserializeObject

最新更新