The type or namespace name 'Json' does not exist in the namespace 'System' (are you missing an assembly reference?)

不想你离开。 提交于 2020-03-23 08:41:46

问题


I am using .NET Framework 4.5 and I'm having this issue. The type or namespace 'Json' does not exist in the namespace 'System'

So, I tried to Install-Package System.Json -Version 4.0.20126.16343 but I had this issue afterwards.

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'

Source: https://www.nuget.org/packages/System.Json

Any ideas would be really appreciated!


回答1:


That package is discontinued and shouldn't be used any more.

If you have a console application, I could recommend two options:

  • JSON.NET. Not a part of the .NET Framework itself, but much faster than Microsofts implementation;
  • Microsofts implementation of the JavaScriptSerializer.

Both are capable of reading and writing JSON. I find the JSON.NET library easier to use and more feature complete.




回答2:


using Newtonsoft.Json; Should get the job done

now you can use :
JsonConvert.SerializeObject JsonConvert.DeserializeObject



来源:https://stackoverflow.com/questions/30863514/the-type-or-namespace-name-json-does-not-exist-in-the-namespace-system-are

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!