Skip to content

MapType of styled_map, fails to deserialize.. #174

@mistyn8

Description

@mistyn8

UMB 13.3.2 and GMaps 3.0.2

In the property convertor deserialising with System.Text.Json is failing for me when mapType is map_styled works with other options
https://github.com/ArnoldV/Our.Umbraco.GMaps/blob/develop/Our.Umbraco.GMaps.Core/PropertyValueConverter/SingleMapPropertyValueConverter.cs#L43
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] public MapType? MapType { get; set; }

I don't think when using System.Text.Json the JsonStringEnumConvertor supports snake_case EnumMember

If I replace the convertor with my own simply reverting to newtonsoft it's back working...

//model = JsonSerializer.Deserialize<Map>(jsonString);
model = Newtonsoft.Json.JsonConvert.DeserializeObject<Map?>(jsonString);

Having a look around and seems lots of issues supporting enums with snake case, hamburger case... and doesn't seem to be a quick googled solution :-( In my limited understanding it seems that JsonStringEnumConverter is only allowing matching on lowercased propertyname and not respecting the actual EnumMember?

Although JsonStringEnumConverter does address the straight conversion between an enum and its direct string representation, it does not in fact address cases where the string is not a direct match to the enum value.

dotnet/runtime#74385

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions