6

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?

DiPix
  • 5,755
  • 15
  • 61
  • 108

2 Answers2

5

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.

stelioslogothetis
  • 9,371
  • 3
  • 28
  • 53
  • 4
    ASP.NET Core already uses JSON.NET from Newtonsoft for de-/serializing the json results – Tseng May 10 '17 at 20:08
  • You are correct sir. Edited accordingly. – stelioslogothetis May 10 '17 at 20:13
  • @Tseng does that mean one doesn't even have to install it via Nuget? – J86 Jan 02 '18 at 10:56
  • @Ciwan: Correct, unless you wannt a newer version of JSON.NET for whatever reason (bugfix?) and of course if you create a Portable Class Library which do not reference the ASP.NET Core assemblies which depend on JSON.NET – Tseng Jan 02 '18 at 11:40
-3

I think you can use it without adding any middleware. Follow how to use it on http://www.newtonsoft.com/json