Skip to content
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

Workaround Polymorphic System.Text.Json issue by forcing $type dup removal #179

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

drasticactions
Copy link
Owner

@drasticactions drasticactions commented Jan 22, 2025

Fixes #178

There is a bug with Polymorphic objects with System.Text.Json where it will add duplicated types to the serialization, which effects $type. Trying to work around it has been tough, since you can't manipulate the JsonNode directly, so for the moment I wrote a very blunt and dumb string manipulation where

  • $type is always the first item serialized
  • If it's twice in a row, remove the second one

This should fix ToJson and POSTs to ATProtocol endpoints.

It's dumb, but it works™

@drasticactions drasticactions merged commit 2fdb494 into develop Jan 22, 2025
6 checks passed
@drasticactions drasticactions deleted the test-json-fix branch January 22, 2025 09:28
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.

Using ToJson adds extra $type parameter to top and bottom of serialized item
1 participant