Closed nssidhu closed 2 years ago
I used the suggestion from this post and now using json.net since it provide the capability to write custom convert.
Hi @nssidh,
The JSON serialiser is replaceable. See the server sample project for an example where it has been replaced with a Newtonsoft JSON one (samples/BlazorServer/Program.cs)
builder.Services.Replace(ServiceDescriptor.Scoped<IJsonSerializer, NewtonSoftJsonSerializer>()); This one replaces for the whole application.
Is there one just for your Blazored Component ( and that too may be temporarily for such odd objects and then revert back to default one) ?
This is for Blazored LocalStorage. The IJsonSerializer interface is from this library.
Closing as there is nothing else to do.
I am trying to store object that has
await _localStorage.SetItemAsync<AuthInfo>("AuthInfo",authInfo);
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'System.Security.Claims.Claim'. Path: $.Claims[0] | LineNumber: 9 | BytePositionInLine: 5.
Do i have option to instead use newtonsoft for serialization & deserialization ?