我只是在为 Facebook 朋友对象编写一些转换代码,我尝试使用json2csharp 转换器,它似乎创建了很多类来提供结构。
JSON
{
"data": [
{
"name": "Name1",
"id": "34535345",
"picture": {
"data": {
"url": "https://fiamge.jpg",
"is_silhouette": false
}
}
},
{
"name": "Name2",
"id": "23424234",
"picture": {
"data": {
"url": "https://fimage.jpg",
"is_silhouette": false
}
}
}]
}
CSharp json2csharp
public class Data
{
public string url { get; set; }
public bool is_silhouette { get; set; }
}
public class Picture
{
public Data data { get; set; }
}
public class Datum
{
public string name { get; set; }
public string id { get; set; }
public Picture picture { get; set; }
}
public class RootObject
{
public List<Datum> data { get; set; }
}
对于一段相当简单的 JSON,似乎有很多类。有没有办法解决对 Picture -> Data 关系的需求而只拥有 Picture 类?