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

[Blazor webasm] Please provide global way to set JSON serialization settings #38144

Closed
astrowalker opened this issue Nov 6, 2021 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@astrowalker
Copy link

When defaults suffice it is good and all but after some time one add some JSON converter (or switch to Newtonsoft), so please make life for Blazor client side equally easy as it is for server side. Namely please provide counterparts for those methods:

            services.AddControllers() // server side
                .AddJsonOptions(json => customization...))
                .AddNewtonsoftJson(json => customization...))
                ;

If you call the second or third method you will get serialization set once and for good. On the server side.

So it would be great to have something similar -- i.e. one call -- for Blazor client side.

@javiercn
Copy link
Member

javiercn commented Nov 8, 2021

@astrowalker thanks for contacting us.

We don't plan to add more extensibility in this area, as it can affect the way Blazor fundamentally serializes some of its core messages and data structures and have a negative impact on the application performance, reliability (and even security) that is really hard to debug and troubleshoot.

That said, we offer efficient binary serialization since 6.0 and you can leverage that to build your own helper methods for serializing and deserializing data in whatever way you see fit, (whether that is JSON, protocol buffers, or any other serialization scheme). If you need that level of control, we recommend you do so for your app.

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Nov 8, 2021
@mkArtakMSFT
Copy link
Member

Thanks @javiercn. This is also related to #12685, where we basically said the same.

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Nov 8, 2021
@ghost ghost added the Status: Resolved label Nov 8, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants