[英]Deserializing json string
I am having some json problems. 我遇到一些json问题。 I receive this json string that I need to convert to a C# object. 我收到了我需要转换为C#对象的json字符串。 But I cannot figure out how to create the class. 但是我不知道如何创建类。
It's the “80” and “81” that's bothering me – it's data, not datatypes. 困扰我的是“ 80”和“ 81” –是数据,而不是数据类型。 How should the classes be defined, in order to deserialize this string using JsonConvert 为了使用JsonConvert对字符串进行反序列化,应该如何定义类
Thanks. 谢谢。
{
"type": "offer",
"locations": {
"80": [
[0.9668122154477, 1.2264154397082],
[0.9668122154477, 0.17307269895365],
[1, 0.17307269895365],
[1, 1.2264154397082]
],
"81": [
[0, 1.2264154397082],
[0, 0.17307269895365],
[0.50429990148833, 0.17307269895365],
[0.50429990148833, 1.2264154397082]
]
},
"id": "edcfPmWm",
"run_from": 1385161200,
"run_till": 1385765999,
"heading": "Q-line udend\u00f8rs julebelysning",
"webshop": null
}
Here is the most basic class with just the fields that fit your needs (you'd need accessors and so on). 这是最基本的类,只包含满足您需要的字段(您需要访问器等)。
public class YourJsonData
{
private string type; // could be an enum
private string id;
private int timestampFrom;
private int timestampTill;
private string heading;
private string webshop;
private Dictionary<int, List<List<double>>> locations;
}
NB: Are you asking for a specific class that encapsulates the List<List<double>>
? 注意:您是否要求封装List<List<double>>
的特定类?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.