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

Migrate from Newtonsoft.Json to System.Text.Json #231

Open
JamieMagee opened this issue Aug 26, 2022 · 3 comments
Open

Migrate from Newtonsoft.Json to System.Text.Json #231

JamieMagee opened this issue Aug 26, 2022 · 3 comments
Labels
status:ready Ready to start implementation type:refactor Refactoring or improving of existing code

Comments

@JamieMagee
Copy link
Member

For a long time Newtonsoft.Json was the best JSON library for .NET. However, since System.Text.Json was added in .NET Core 3.0, it's clearly the future. It's a core part of .NET, so there's no need for an additional dependency, and it's far more performant than Newtonsoft.Json

A couple of things to be aware of:

References:

@JamieMagee JamieMagee added good first issue Good for newcomers status:ready Ready to start implementation type:refactor Refactoring or improving of existing code labels Aug 26, 2022
@pn04
Copy link

pn04 commented Aug 30, 2022

Hi @JamieMagee , I would like to take a stab at it, if this has not been picked up already.
Could you answer some of the queries I have, please

Should we explicitly add JsonPropertyName attributes to object properties?

just want to understand the reasoning behind this. I am assuming that JsonProperty attribute can be replaced with JsonPropertyName attribute. But, are you suggesting that we add JsonPropertyName on all object properties? One place, where we have to do this is all the models where JsonObject attribute is used currently, because I think System.Text.Json doesn't have any such attribute.

Should we standardize on Camel Case (exampleVariableName) over PascalCase (ExampleVariableName)?

I saw some classes where CamelCaseNamingStrategy is used but could not find any where PascalCase is being used

Newtonsoft.Json can accept both by default, can System.Text.Json too?

The only built-in property naming policy in System.Text.Json is for camel case
We'll have to write custom naming policy to support PascalCase

@tevoinea
Copy link
Member

Another thing to take into consideration (I tried this before -- maybe last year?) is maintaining the manifest output contract. If I remember correctly, there had to be some custom serializer implementations to make it line up.

@JamieMagee
Copy link
Member Author

@tevoina thanks for the pointers

@pn04 based on the info Teo shared someone from the Microsoft side will likely have to pick this item up. Thank you for volunteering though ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready Ready to start implementation type:refactor Refactoring or improving of existing code
Projects
Development

No branches or pull requests

3 participants