相关疑难解决方法(0)

C#操作JSON数据

我有一个"简单"的场景:读取一些JSON文件,过滤或更改一些值并将结果写回json,而不更改原始格式.

所以例如改变这个:

{
  "type": "FeatureCollection",
  "crs": {
    "type": "EPSG",
    "properties": {
      "code": 28992
    }
  },
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              149886.192,
              374554.705
            ],
            [
              149728.583,
              374473.112
            ],
            [
              149725.476,
              374478.215
            ]
          ]
        ]
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

进入:

{
  "type": "FeatureCollection",
  "crs": {
    "type": "EPSG",
    "properties": {
      "code": 28992
    }
  },
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": 
            [
              149886.192,
              374554.705
            ]
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过newtonsoft等JSON.Net,但我能找到的只有:

  • 读入对象
  • 将对象写入json …

c# json json.net

17
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

json ×1

json.net ×1