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

Revisited: Umbraco v8 (GMaps: 1.3.3) to Umbraco v10 (GMaps 3.0.0) legacy data value converter issues #171

Open
mistyn8 opened this issue Apr 30, 2024 · 0 comments

Comments

@mistyn8
Copy link
Contributor

mistyn8 commented Apr 30, 2024

related issue #165
related pr The fix

I seem to be hitting this problem too, but my pre version 2 data has Zoom as an int?

{
    "address": {
        "latlng": "55.7718077578719, -4.06716364655761",
        "full_address": "1 Wellhall Rd",
        "postalcode": "ML3 9BZ",
        "state": "Scotland",
        "country": "United Kingdom"
    },
    "mapconfig": {
        "zoom": 15,
        "maptype": "Roadmap",
        "mapcenter": "55.7721095233427, -4.067592799999993"
    }
}

It then fails to deserialise to the LegacyMap Model. Perhaps the fix is to allow for either? (went a simple approach rather than creating a custom convertor)

    public class LegacyMapConfig : MapConfig
    {
        [JsonProperty("mapcenter")]
        [JsonPropertyName("mapcenter")]
        public string MapCenter { get; set; }

        [Newtonsoft.Json.JsonIgnore]
        [System.Text.Json.Serialization.JsonIgnore]
        public new string Zoom { get; set; }

        [JsonProperty("zoom")]
        [JsonPropertyName("zoom")]
        public object _value
        {
            get
            {
                if (int.TryParse(Zoom, out var intValue)) return intValue;
                return this.Zoom;
            }
            set { this.Zoom = value.ToString(); }
        }
    }
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