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

still need Newtonsoft.Json #15962

Closed
infofromca opened this issue May 3, 2024 · 14 comments
Closed

still need Newtonsoft.Json #15962

infofromca opened this issue May 3, 2024 · 14 comments

Comments

@infofromca
Copy link
Contributor

infofromca commented May 3, 2024

Is your feature request related to a problem? Please describe.

after the commit of remove Newtonsoft.Json, my api could not give the correct json to client side . I tried many ways and made sure only Newtonsoft.Json can reach my purpose.

Describe the solution you'd like

are there any way to comparable both Newtonsoft.Json and System.Text.Json

Describe alternatives you've considered

Now I only go inside src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs and add back builder.AddNewtonsoftJson(); , which is not elegant.

// Add a route endpoint selector policy.
services.AddSingleton<MatcherPolicy, FormValueRequiredMatcherPolicy>();

// There are some issues when using the default formatters based on
// System.Text.Json. Here, we manually add JSON.NET based formatters.
builder.AddNewtonsoftJson();
services.AddModularRazorPages();
@MikeAlhayek
Copy link
Member

after the commit of remove Newtonsoft.Json, my api could not give the correct json to client side . I tried many ways and made sure only Newtonsoft.Json can reach my purpose.

What does your API returns now and what is it supposed to return? It would be good to share JSON response sample.

@Piedone Piedone added this to the 2.0 milestone May 3, 2024
@Piedone
Copy link
Member

Piedone commented May 7, 2024

Can you please provide further information, @infofromca? This potentially blocks the 2.0 release.

@infofromca
Copy link
Contributor Author

Sorry, I cannot provide the data which belongs to a bank

@hishamco
Copy link
Member

hishamco commented May 7, 2024

Please provide a sample not necessarily actual data to make it easier to see the bug if there is

@Piedone
Copy link
Member

Piedone commented May 7, 2024

Unfortunately, we'll only be able to help if we get more information from you, because this is not something we can work with at this point.

And yeah, we'd need a minimal repro as a starting point. While creating that, you might discover that the issue is specific to some custom code of yours.

@Piedone
Copy link
Member

Piedone commented May 7, 2024

And maybe you could give a demo of the app, to an extent possible to do publicly, on the Tuesday meeting, so we can say a bank uses OC :).

@hishamco
Copy link
Member

hishamco commented May 7, 2024

Lol

@infofromca
Copy link
Contributor Author

infofromca commented May 7, 2024

Although it was not elegant, I found a workaround about it.
I add the following code in the startup.cs of my custom module:

var builder = services.AddMvc();
           

// There are some issues when using the default formatters based on
// System.Text.Json. Here, we manually add JSON.NET based formatters.
builder.AddNewtonsoftJson(options =>
{
    // Use the default property (Pascal) casing
    // options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});

If it is needed, we can add this to the doc.

@hishamco
Copy link
Member

hishamco commented May 8, 2024

Please check different options in JsonSerializerOptions https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions?view=net-8.0

@MikeAlhayek
Copy link
Member

@infofromca any updates here? Can we close this issue or you think there is something else that needs to be done?

@infofromca
Copy link
Contributor Author

if we need note on the doc, we can add it. otherwise , close it

@Piedone
Copy link
Member

Piedone commented May 14, 2024

Docs about using JsonSerializerOptions, do you mean?

@infofromca
Copy link
Contributor Author

Maybe it is not neccesary for the doc. just close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants