Skip to content
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

MapType of styled_map, fails to deserialize.. #174

Open
mistyn8 opened this issue Jun 18, 2024 · 2 comments
Open

MapType of styled_map, fails to deserialize.. #174

mistyn8 opened this issue Jun 18, 2024 · 2 comments

Comments

@mistyn8
Copy link
Contributor

mistyn8 commented Jun 18, 2024

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

@mistyn8
Copy link
Contributor Author

mistyn8 commented Jun 18, 2024

Maybe this? dotnet/runtime#31081 (comment)

@mistyn8
Copy link
Contributor Author

mistyn8 commented Jun 18, 2024

Same occurs deserialising the map style for a styled_map, reverting to newtonsoft again resolves.

 // jsontext fails to deserialize this too ???
 //var style = JsonSerializer.Deserialize<MapStyle?>(ms);
 var style = Newtonsoft.Json.JsonConvert.DeserializeObject<MapStyle?>(ms);
 model.MapConfig.Style = style?.Selectedstyle?.Json;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant