question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object not properly deserialized due to case-sensitivity

See original GitHub issue

Hi!

First of all, thanks for the library! It’s great to have possibility to use SignalR in Blazor with C#.

I have an issue with deserialization of an object. There’s an example code attached.

On client side I changed the Index component to subscribe to a hub and added a button to poke a controller on server side that sends an object through the hub.

Problem is, that all strings are empty in the object received in the client in method registered through .On<> (OnPostReceived). The contents of the received message is logged to console:

image

When I looked at the packets through Wireshark they seemed to contain sensible data.

It’s also possible that I’m doing something very wrong.

I’m using strongly-typed hub on the server, but I don’t think it should matter.

BlazorSignalR.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
MiKomcommented, Jul 9, 2019

@dave-bt To work around the problem before the fix is released you can force the Json serializer to always use lowercase property names like that:

    public class Post
    {
        [JsonPropertyName("author")]
        public string Author { get; set; } = "";

        [JsonPropertyName("content")]
        public string Content { get; set; } = "";
    }

You may need to add reference to the System.Text.Json package however if your class is located in netstandard2.1 project (default with Blazor .Shared projects):

  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="4.6.0-preview6.19303.8" />
  </ItemGroup>
0reactions
galvesribeirocommented, Aug 13, 2019

Yes, the current System.Text.Json requires you to use JsonPropertyName.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialize Json to Pojo without case sensitivity - java
Try configuring like below it will work :) @JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) private String name;.
Read more >
How to enable case-insensitive property name matching ...
By default, deserialization looks for case-sensitive property name matches between JSON and the target object properties.
Read more >
Solving .NET JSON Deserialization Issues
The first way to fix this issue is to use a different set of options for the JsonSerializer . For example, we can...
Read more >
Case insensitive deserialization - NotesSensei's Blog
This poses a challenge when deserializing (handcrafted) JSON files. The Task at hand. Deserialization of JSON into a Java class instance can be ......
Read more >
How do you fix the wrong-case-sensitivity dictionary setting ...
So, we can deserialize JSON or SQL rows or whatever, to fill in the properties dictionary. By seemingly good luck, our JSON serializer ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found