Skip to content

Switch more over to System.Text.Json #9819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 26, 2025
Merged

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Feb 21, 2025

  • JsonElement is read only. This is why we convert them to JsonNode.
  • JsonNode.Parse does NOT have the same features as JsonDocument.Parse. e.g you CANNOT tell it to ignore trailing comma's. It will just throw an exception. This is the reason why we have to load the .json via JsonDocument and then call the extension method .ToNode () on the Root JsonElement to convert it to a JsonNode. (We use JsonNode to do the merging).

@dellis1972 dellis1972 force-pushed the dev/dellis1972/systemtextjson branch from 06ec5dd to 7fda7e5 Compare February 21, 2025 16:42
@dellis1972
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dellis1972 dellis1972 marked this pull request as ready for review February 25, 2025 16:01
@dellis1972 dellis1972 requested a review from jonpryor as a code owner February 25, 2025 16:01
@@ -116,7 +116,6 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Options.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Options.pdb" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)MULTIDEX_JAR_LICENSE" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Newtonsoft.Json.dll" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is System.Text.Json in the pack?

It would be needed for .NET framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Probably. We need to figure out how to get #9727 and #8746 working so we can test under .NET framework to catch all this stuff.

@jonpryor
Copy link
Contributor

WIP commit message:

[Xamarin.Android.Build.Tasks] Remove use of Newtonsoft.Json (#9819)

Context: https://github.com/dotnet/android/issues/9229

Remove use of Newtonsoft.Json from `Xamarin.Android.Build.Tasks.dll`.

Notes:

  * `JsonElement` is read only.  This is why we convert them to
    `JsonNode`.

  * `JsonNode.Parse()` does NOT have the same features as
    `JsonDocument.Parse()`, e.g you CANNOT tell it to ignore trailing
    comma's; it will just throw an exception.  This is the reason why
    we have to load the `.json` via `JsonDocument` and then call the
    extension method `.ToNode ()` on the Root `JsonElement` to convert
    it to a `JsonNode`.  (We use `JsonNode` to do the merging).

Question: does this PR fix #9229?

@jonpryor jonpryor merged commit 21e69b4 into main Feb 26, 2025
58 checks passed
@jonpryor jonpryor deleted the dev/dellis1972/systemtextjson branch February 26, 2025 20:01
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants