如何将JSon转换为IPoint类型?

时间:2019-02-28 19:27:41

标签: c# asp.net-core json.net

我有一个JSON文件,其中的一个属性是:

"Location": {
  "Latitude": 38.7080404,
  "Longitude": -9.1436747
}

我有一些带有Location属性的类:

public class Example {
  public IPoint Location { get; set; }
}

可以如下创建一个IPoint:

Example example = new Example();
example.Location = new Point(new Coordinate(latitude, longitude)) { SRID = 4326 };

如何定义Newtonsoft JSon.Net规则以将JSON转换为IPoint类型的任何属性?

0 个答案:

没有答案