How can I use Newtonsoft: Json.NET in ASP.NET Core WebAPI?

45,033

You don't need to do anything special to get Newtonsoft.JSON to work. Simply install it through NuGet (or manually) and you're good to go. You will however have to go through your code and replace any code you wrote to work with JSON before installing it.

EDIT: You dont even have to do that! Turns out .Net Core uses it out of the box. Refer to this answer for how to use it natively.

UPDATE: From the answer linked above:

This is only true for ASP.NET Core 1.0 to 2.2. ASP.NET Core 3.0 removes the dependency on JSON.NET and uses it's own JSON serializer.

As for performance, there are a few benchmarks out there that compare alternative ways of serializing and deserializing JSON. A quick google search led me to this, as well as this.

Share:
45,033
DiPix
Author by

DiPix

Updated on July 09, 2022

Comments

  • DiPix
    DiPix almost 2 years

    I found some information about nuget package - Newtonsoft: Json.NET

    As far I know it makes serialization from JSON to C# object much faster.

    My question: Is it enough to install this package to my ASP.NET CORE WebAPI project or I have bind it somehow, dunno maybe with middleware or something? And it will makes serialization faster?