12

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'

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!

4
  • What does this mean do you think? "The owner has unlisted this package. This could mean that the package is deprecated or shouldn't be used anymore." Commented Jun 16, 2015 at 9:21
  • I understand. So if I don't use this then, what's your solution on this? Regards,Pavlos Commented Jun 16, 2015 at 9:22
  • What kind of application are you creating? Commented Jun 16, 2015 at 9:22
  • A really simple console application to convert a custom xml to json Commented Jun 16, 2015 at 9:24

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I already use this, but as I described above, the error that I have is that "The type or namespace name 'Json' does not exist in the namepsace 'System' "
System.Json isn't the namespace of either of those. It is either Newtonsoft.Json or System.Web.Script.Serialization.
That package is discontinued - I think it's worth adding for .NET Framework 4.5, which the OP referred to? today it's built in into .NET Core 3.0 and later versions, and can be installed as a NuGet package for .NET Standard 2.0 and later versions, .NET Framework 4.7.2 and later versions, and .NET Core 2.0, 2.1, and 2.2 (doc).
3

using Newtonsoft.Json; should get the job done.

Now you can use:

JsonConvert.SerializeObject
JsonConvert.DeserializeObject

2 Comments

this is more of a comment than an answer
Also it doesn't solve the actual problem of needing to use System.Text.Json. In my case it's a requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.