Base solution for your next web application
Open Closed

JSON serialization settings #328


User avatar
0
klimaxx created

Hi

I have come to a problem deserializing json to dto using polymorphism. This could be fixed using JsonSerializerSettings TypeNameHandling = auto. Unfortunately abp uses hardcoded JSONSerializerSettings.

return JsonConvert.DeserializeObject<TObj>(str, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });

So there is no way to override it specifying JsonConvert.DefaultSettings. I think you can setup json default settings semewhere during bootstrap and in code use just DeserializeObject without specifying JsonSerializerSettings.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    TypeNameHandling may not be a good idea. Because in that case, you will send class names from javascript. But OK, you may need it. Currently, it's hardcoded as you saw. Can you create an issue on Github for that. We will consider to resolve it in next versions. Thanks.