I have the following class. I am trying to deserialize Json into an array of these LookUpData objects:
[DataContract]
public class LookUpData
{
[DataMember]
public string Id { get; set; }
[DataMember]
public GeographyPoint Location { get; set; }
}
}
The Json data looks like this:
{
"Id": "123",
"Location": {
"Latitude": 1,
"Longitude": -1,
}
}
},
I want to create a custom Json Deserializer so that when reading the Json and hits 'Location', it will create a new GeographyPoint type at that moment, from the Latitude and Longitude values.
I have looked at Newtonsoft's documentation at the Custom Json Serializer as well as helpful answers on Stack Overflow such as this one Custom Deserialization using Json.NET already, but I can't find an example of how to actually create a new type when deserializing. For example the error I receive at the moment using the standard deserializer is 'Could not create an instance of type Microsoft.Spatial.GeographyPoint. Type is an interface or abstract class and cannot be instantiated".
I'd be grateful if anyone could please point me in the right direction here. Thanks!