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

🔖 🐛 Fix for #165 legacy data value converter issues #169

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

robertjf
Copy link
Collaborator

@robertjf robertjf commented Feb 9, 2024

No description provided.

@robertjf robertjf merged commit 3e37d2a into ArnoldV:develop Feb 9, 2024
1 check passed
@mistyn8
Copy link
Contributor

mistyn8 commented Apr 29, 2024

@robertjf 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(); }
        }
    }

@robertjf
Copy link
Collaborator Author

@mistyn8 can you create a separate issue and attach a PR perhaps?

@mistyn8
Copy link
Contributor

mistyn8 commented Apr 30, 2024

@robertjf sure.. PR here #172

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

Successfully merging this pull request may close these issues.

2 participants