puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

Replace Newtonsoft.Json package with System.Text.Json

Open NCLnclNCL opened this issue 2 years ago • 11 comments

We use Newtonsoft.Json package to serialize/deserialize json. It is great library. But seems json is becoming built-in format in BCL (.net 6). In future it allow us to be not dependent on any 3rd-party libraries. We will produce multi-targeted package:

netstandard2.0 - depends on System.Text.Json net6.0 - has no dependencies Newtonsoft.Json dont support native aot but System.Text.Json support with source generator

NCLnclNCL avatar Nov 20 '23 04:11 NCLnclNCL

Feel free to play with that! :)

kblok avatar Nov 21 '23 14:11 kblok

Feel free to play with that! :)

I did not understand

NCLnclNCL avatar Nov 21 '23 15:11 NCLnclNCL

@NCLnclNCL you can go and implement that. You are free to go.

kblok avatar Nov 21 '23 15:11 kblok

@NCLnclNCL if you can go and implement that. You are free to go.

But why you donot it

NCLnclNCL avatar Nov 24 '23 18:11 NCLnclNCL

@NCLnclNCL if you go to implement that. You are free to go.

But why you donot it

Because I have another 100 issues to work on and I might need some help?

kblok avatar Nov 24 '23 18:11 kblok

@NCLnclNCL if you go to implement that. You are free to go.

But why you donot it

Because I have another 100 issues to work on and I might need some help?

I think it is hard

NCLnclNCL avatar Dec 04 '23 15:12 NCLnclNCL

There is an additional problem with Newtonsoft.Json dependency - it is not trimmable: https://github.com/JamesNK/Newtonsoft.Json/issues/2813. Thus, PuppeteerSharp users will see related trim warnings.

On the other side, System.Text.Json does not lead to any trim warnings.

shibaev avatar Dec 20 '23 03:12 shibaev

There is an additional problem with Newtonsoft.Json dependency - it is not trimmable: JamesNK/Newtonsoft.Json#2813. Thus, PuppeteerSharp users will see related trim warnings.

On the other side, System.Text.Json does not lead to any trim warnings.

If possible, you can convert it, or at least use regex instead json haha, I feel like the 2 libraries are quite different and the conversion is extremely difficult

NCLnclNCL avatar Dec 20 '23 03:12 NCLnclNCL

The following migration guide might be useful: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-8-0

shibaev avatar Dec 20 '23 03:12 shibaev

The following migration guide might be useful: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-8-0

I appreciate if you can convert

NCLnclNCL avatar Dec 20 '23 11:12 NCLnclNCL

This ticket is also important for AOT deployment support (publish with PublishAot = true). Newtonsoft.Json is unlikely to support that ever: https://github.com/JamesNK/Newtonsoft.Json/issues/2732

shibaev avatar Mar 06 '24 07:03 shibaev