Configure JsonSerializationOptions for WASM Interop in Blazor?
I need to configure JSON serialization in Blazor wasm. I want to use/provide custom JsonContext.. specifically its type info
51 Replies
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I thought it was clear. It's obvious that I'm asking some extension method on DI service collection to configure the way Blazor receives objects when invokes js functions. I'm asking if there's a way to provide JsonTypeInfo to use source generated version and optimize interop calls
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
why not??
Instead of controller, wouldn't be nicer to have some configuration for wasm di services?
like:
Are you telling me that something like this doesn't exists?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I know, I just asked for something similar, in order to optimize JSInterop in blazor using source generated and not runtime serializer
Since it's something that I might do regular, I think it should be something provided by author I guess
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
JSInterop should use something generic to "pass" params to JS invokes
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
no man, I don't know how microsoft does to pass objects to JSRuntime.InvokeAsync
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
but I guess theres a serialization in the middle
that's sounds awful
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I though of JsonSerializationContext inheritance
even thus, how would I use it in JSRuntime.InvokeAsync?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I was requested to create a wrapper for a js datagrid component

Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
it's private
TeBeCo
like a
dotnet new blazor-wasm
+ example of 3-4 calls that have the issueQuoted by
<@689473681302224947> from #Configure JsonSerializationOptions for WASM Interop in Blazor? (click here)
React with ❌ to remove this embed.
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
this is the critical part
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
man, I was given a private repo, extract that would mean to provide license
for example?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
the portion of code in the picture is all about
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
ASP.NET Core Blazor JavaScript interoperability (JS interop)
Learn how to interact with JavaScript in Blazor apps.
I'll take a look wait
You can use the
JsonConverter
annotationI see
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
it's fixed serialization by MS
yes for back compat reasons
but you can customize your own types
No worries I'll gladly google the docs for you :)
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
mmmm... like the attribute?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
yes
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
so, it would be over the collection type
I'll try and see
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
you know what? I completely forgot that
How didn't I thought of this?
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
Yeah, I've seen it, didn't remember since I was flawed to using source generators instead of the variants that already existed and I didn't know they could work.
my bad
thanks
any other advises would be highly appreciated @SleepWellPupper @TeBeCo
Is it possible to combine custom converter annotations with SG'd serialization?
I would love it if possible
Is your only concern to avoid reflection when invoking functions you control?
I encourage you to $tias as I will be unavailable for a bit. I'd be interested as well.
yeah. I'm thinking of: it's a datagrid control, I would love to be @foreach over rows, but not like that. JS takes all the configuration, even rows
instead (maybe overthinking or overengineering) I prefer to reduce the amount of memory being used. Eg: a 10000 rows makes it slow to pass for jsInvoke. I suggested to allow HTML define table rows. but they don't use tables.. 😕
good part it's just first time until next time source gets refreshed. Meaning, manipulate data in the datagrid control is managed by a js lib. but refreshing that datasource with JSInterop I perceive a cost
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/virtualization?view=aspnetcore-9.0
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/quickgrid?view=aspnetcore-9.0
Have you seen these?
ASP.NET Core Razor component virtualization
Learn how to use component virtualization in ASP.NET Core Blazor apps.
ASP.NET Core Blazor
QuickGrid
componentThe QuickGrid component is a Razor component for quickly and efficiently displaying data in tabular form.
virtualization good, quickgrid component..mmm client wants his own js lib wrapper
First thing I proposed was to use QuickGrid
he kicked it out
hit it hard for homerun, like we Cubans say
a shame
oh well