Skip to content

Conversation

@TP125487
Copy link
Contributor

Hi,

I have changed the JSON implementation from Newtonsoft.Json to System.Text.Json.

We know this is a big one.

Why do we want to change the JSON serializer?

  • Newtonsoft.Json is no longer state-of-the-art.
  • .NET 5 and ongoing have its own Json serializer implementation.
  • One package less to depend on.
  • Cleaner code (no need for NullValueHandling = NullValueHandling.Ignore, etc.). Said option is now set in ‎DefaultJsonSerializerOptions.cs.

All testes are passing. The hash sum of one test (URL) had to be changed because an unneeded field that was there beforehand is no longer present in the resulting JSON.

A few fields had to be changed from dynamic to object. But the resulting JSON is the same. System.Text.Json does not support dynamic.

What I am not 100% sure is if it works correctly is the [JsonExtensionData] tag.

Could you please provide some example data for the Options field for CaptureWebsiteCreateRequest, so I can compare the resulting Jsons of Newtonsoft and System.Text.Json? Thank you.

Implements #8.

@josiasmontag
Copy link
Contributor

Thanks for your work!

I don't think this works correctly with the Options field. The Options payload should be basically just merged into the task payload. An example is in the README: https://github.com/cloudconvert/cloudconvert-dotnet?tab=readme-ov-file#conversion-specific-options

I have created a integration test in master to check if this works correctly:
d842282

Could you merge master into your branch? The new test should help to make sure this works.

@TP125487
Copy link
Contributor Author

Thanks for the quick reply!

It does actually work. :) I have converted the newly added test case for System.Text.Json.

@josiasmontag
Copy link
Contributor

Awesome!

@josiasmontag josiasmontag merged commit b49b38d into cloudconvert:master Mar 18, 2025
1 check passed
@TP125487
Copy link
Contributor Author

Thank you!

@TP125487 TP125487 deleted the convert-to-system-text-json branch March 18, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants