简体   繁体   English

使用不带属性名C#的嵌套数组反序列化JSON

[英]Deserialize JSON with nested arrays without property name C#

I have an array with following data schema 我有一个具有以下数据架构的数组

"coordinates" : [
      [
        [
          482035.87650000025,
          3768510.0446000006,
          0
        ],
        [
          482035.86720000021,
          3768514.4123,
          0
        ],
        [
          482035.68240000028,
          3768514.4119000006,
          0
        ]
      ]
  ]

What is the correct mapping class structure for Deserialize this json string into object using Newtonsoft Json 使用Newtonsoft Json将此json字符串反序列化为对象的正确映射类结构是什么

If you'd wrap that in { } to make it a valid JSON object, this should be the class: 如果将其包装在{ }以使其成为有效的JSON对象,则应为此类:

public class RootObject
{
    public List<List<List<double>>> coordinates { get; set; }
}

string adjustedFragment = "{ " + json + " }";
RootObject r = JsonConvert.DeserializeObject<RootObject>(adjustedFragment);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM