hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.34k stars 439 forks source link

Replace Newtonsoft.Json package with System.Text.Json #2362

Open NCLnclNCL opened 9 months ago

NCLnclNCL commented 9 months ago

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

kblok commented 9 months ago

Feel free to play with that! :)

NCLnclNCL commented 9 months ago

Feel free to play with that! :)

I did not understand

kblok commented 9 months ago

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

NCLnclNCL commented 9 months ago

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

But why you donot it

kblok commented 9 months ago

@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?

NCLnclNCL commented 9 months ago

@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

shibaev commented 8 months ago

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.

NCLnclNCL commented 8 months ago

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

shibaev commented 8 months ago

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

NCLnclNCL commented 8 months ago

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

shibaev commented 6 months ago

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