-
Notifications
You must be signed in to change notification settings - Fork 21
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
Using this with clientside blazor #32
Comments
@americanslon Are you referring to this technologie? Could you provide the client sample code that fails, please? |
Yep that's the one. |
Please let me help you by providing a code sample! |
There is nothing to provide....I don't understand how to set this up. |
What I am expecting is the code where you call GetJsonAsync or something similar to be sure I'm looking at the right API Anyway, by digging into this technology, I noticed that there is no way to provide a JsonSerializerOptions instance to their HttpClient extension. You need to call Dahomey.Json extension method SetupExtension on JsonSerializerOptions in order to let polymorphism work. the issue corresponding to this problem is here: and the task to implement a better HttpClientExtensions is However, you could implement it yourself, starting from for instance public static async Task<T> GetJsonAsync<T>(this HttpClient httpClient, string requestUri)
{
var stringContent = await httpClient.GetStringAsync(requestUri);
return JsonSerializer.Deserialize<T>(stringContent, JsonSerializerOptionsProvider.Options);
} would be modified into public static async Task<T> GetJsonAsync<T>(this HttpClient httpClient, string requestUri, JsonSerializerOptions options)
{
var stringContent = await httpClient.GetStringAsync(requestUri);
return JsonSerializer.Deserialize<T>(stringContent, options);
} Hope it helps |
Do you know how this can be setup in the client side blazor to deserialized based on the descriminator.
The serialization on the net.core web api side works great,
_t
gets added but the blazor side is not aware of_t
and doesn't deserialize into derived types.The text was updated successfully, but these errors were encountered: