在C#中创建嵌套JSON对象[关闭]

0sgqnhkj  于 5个月前  发布在  C#
关注(0)|答案(1)|浏览(92)

已关闭。此问题需要details or clarity。目前不接受回答。
**要改进此问题吗?**通过editing this post添加详细信息并阐明问题。

2天前关闭。
Improve this question
我正在尝试创建一个JSON对象,结果如下。我不知道如何处理所有的嵌套。有人能帮我吗?

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            12.82114,
            56.6762238
          ],
          [
            12.8211,
            56.67633
          ],
          [
            12.82085,
            56.67668
          ],
          [
            12.82106,
            56.6767
          ],
          [
            12.82135,
            56.67675
          ],
          [
            12.82164,
            56.67683
          ],
          [
            12.82188,
            56.67693
          ]
        ]
      },
      "properties": {
        "stroke": "blue"
      }
    }
  ]
}

字符串

weylhg0b

weylhg0b1#

试试这样的东西:

public class Geometry
{
    public string type { get; set; }
    public List<List<double>> coordinates { get; set; }
}

public class Properties
{
    public string stroke { get; set; }
}

public class Feature
{
    public string type { get; set; }
    public Geometry geometry { get; set; }
    public Properties properties { get; set; }
}

public class FeatureCollection
{
    public string type { get; set; }
    public List<Feature> features { get; set; }
}

字符串

相关问题