-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Serialization/Deserialization in .net core 5.0 #360
Comments
Yea, we use newtonsoft converters to handle some special cases, like the one you mention where the base type (an abstract) has multiple derived types. Our converter picks the correct type at runtime. To support system.text.json, we need to do the same. |
What do you mean 'our converter'? Is it provided with the library? How can I use it? do you have any sample of json serialization/dserialization ? |
Sure - it's here: All the converters are here: So yea - it's included and used in the client. I'm a bit curious though. Why would you get that exception when serializing stuff? .. I'd expect it if you were deserializing data, as this is where the concrete type needs to be identified. |
Do you have any current plans to switch to using System.Text.Json classes? |
No. But I could take a look at it. If you wanted, you could also try changing out the serializer and seeing if it can become workable. Alternatively, I could also make it easier to use the serializer I make. |
I could have a little play. I've just grabbed the code and run the tests and unfortunately I've got failing tests so I'm not sure how confident I would be with my changes. Do I need to do anything special to run the tests? |
Some tests are failing right now, which is also (part of) why we don't run tests in CI (the other part being #300). If you make changes and most of the tests work, I'd say that's good enough. There are some "UtilityTests" which I can see are related to json conversion - they test the converters directly, so in reality these tests should be rewritten to use a "TMDbLib Converter" ... which also should be used for all serialization .. Then you could consistently make changes. So basically a small refactoring to pack the newtonsoft dependency into one class, and then replace that class. |
Ah good to know thanks. I might take a look this weekend then. |
I've refactored the serialization into a new
|
There is problem during Json deserialization for list of TvShows which were previously serialized in .net core 5.0 using serializer from System.Text.Json:
var jsonStr = JsonSerializer.Serialize(obj); // obj is List<TvShow>
I got error message:
The text was updated successfully, but these errors were encountered: