-
Notifications
You must be signed in to change notification settings - Fork 20
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
Replacing Newtonsoft.Json with System.Text.Json #88
Comments
All tests are green again, could also verify lots of use cases with my real Xbox One. |
I am happy to provide some samples and such for it. My opinion wasn't asked but: We have some JSON handling but looking at what the python version implements there seems to be a whole lot more over the json channel. |
Newtonsoft.Json is pretty ubiquious, because there was nothing meaningful for JSON part of the standard for a long time. I don't want to doubt that. :) But the .NET Foundation created System.Text.Json to have some fast, stable and small JSON library in the framework itself instead of relying on a 3rd party library. Personally I made pretty good experiences with System.Text.Json in production code. And while it is true that some features (compared to Newtonsoft) are missing, I do not see any fancy stuff in the channel messages that could not be handled with its API. Both are pretty close in their design anyway and this would be more a problem if you migrate from an existing code base which made use of some minions not available on the other side. But I noticed that even in these cases the gaps could be closed with very little custom code easily. |
Maybe that decision should be postponed until all different JSON message bodies and according tests are implemented so we can see if there might be some shortcomings on System.Text.Json in comparison to Newtonsoft.Json. I haven't used System.Text.Json so far, so it's hard for me to judge wether a change to the inbuilt module has needed feature set. |
Not sure whether it is really useful to do all implementation work for currently missing message bodies with Newtonsoft first, doing the switch afterwards. That would be doubled effort. I'd prefer either to stick to Newtonsoft at all or to do the switch early doing the new stuff already with System.Text.Json. From what I have seen so far, channel messages are usually quite small and simple and do not have complexity of large documents with fancy schemas. Missing features are usually related to the serialization part, not deserialization of simple JSON snippets. (see also How to migrate from Newtonsoft.Json to System.Text.Json) Saying so, writing code for System.Text.Json will most likely not block anything (whole ASP.NET Core could replace Newtonsoft, I do assume they have do deal with more complex JSON handling) while migrating code afterwards might require major changes/refactoring if potentially done in a Newtonsoft-specific way with a C# construct that cannot be mapped one-to-one onto System.Text.Json. Maybe we could look at some message bodies not implemented yet and judge based on them, e.g. if there is anything special? |
Currently we are really not gaining any benefit from it because If this change happens, it needs to happen in the webapi project too imho. |
You are talking about SmartGlass.CLI, right? The SmartGlass library itself does not depend on XboxWebApi, and that's what I do depend on. ;) If it is okay for you, keep the issue open at the moment (maybe add a related one to WebAPI and link to this one) and I will take over once I find time and there is less commits here. |
Well XboxWebApi is needed unless you use another way to generate the auth hash/token (or only make anonymous calls) |
I am indeed happy with anonymous calls, that's why I said I do depend on |
To reduce 3rd party dependencies and use netcore standard libraries instead, I'd favor the usage of System.Text.Json over Newtonsoft.Json.
System.Text.Json is also known to be smaller and faster than Newtonsoft.
The text was updated successfully, but these errors were encountered: