Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is using the system.text.json no longer possible for serializing / deserialiing in c#

As described in the official microsoft docs which has been Updated in September of 2019 it says that using system.text.json for serializing or deserializing can be done.

https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to

However when I tried that in a program I was working on , I kept getting the error using system.text.json does not exist

This made me stumble upon this Stack Overflow Question

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

In which as shown above says that the

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

Is there any update on this ? or Is there any way I can work around with system.text.json

like image 390
Devin Avatar asked Dec 27 '19 16:12

Devin


People also ask

Is polymorphic deserialization possible in System text JSON?

There is no polymorphic deserialization (equivalent to Newtonsoft. Json's TypeNameHandling ) support built-in to System.

Is System text JSON faster than Newtonsoft?

Text. Json is much faster than the Newtonsoft. Json.

Which is better Newtonsoft JSON or System text JSON?

Json does case-insensitive property name matching by default. The System. Text. Json default is case-sensitive, which gives better performance since it's doing an exact match.

What is serializing and deserializing JSON in C#?

Serialization is the process of converting . NET objects such as strings into a JSON format and deserialization is the process of converting JSON data into . NET objects.


Video Answer


1 Answers

You just have to install the System.Text.Json NuGet package.

  1. In Solution Explorer select your solution (at the root of the tree) and click with right mouse button.
  2. In the contextual menu choose Manage NuGet Packages for Solutions...
  3. In the window that will appear, click on Browse on the top.
  4. In the search textbox type System.Text.Json
  5. Select the package, then on the right select all the project of your solution for which you want the package to be installed, and then click on the Install button.
like image 76
Fry Simpson Avatar answered Oct 31 '22 23:10

Fry Simpson