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: Ability to set the JsonSerializerOptions.IgnoreNullValues property for JS Interop. #27015

Closed
user72356 opened this issue Oct 18, 2020 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@user72356
Copy link

Blazor appears to have no mechanism to configure the global serialization/deserialization process when making JS Interop function calls. For instance I would like the ability to ignore null values, a facility provided by System.Text.Json via the JsonSerializerOptions.IgnoreNullValues property.

The only way today is to manually serialize my parameters before feeding them into InvokeVoid:

var options = new JsonSerializerOptions
{
    IgnoreNullValues = true
};

var arg = JsonSerializer.ToString<WeatherForecast>(value, options);
@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly and removed feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Oct 19, 2020
@mkArtakMSFT
Copy link
Member

Thanks for contacting us. This is a dupe of #12685
If you want, you can serialize the value as a string and send that (as a JSON object).

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Oct 19, 2020
@ghost ghost added the Status: Resolved label Oct 19, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants