C# 如何解析来自OxfordDictionares api的JSON响应?

C# 如何解析来自OxfordDictionares api的JSON响应?,c#,asp.net,api,C#,Asp.net,Api,如何解析来自OxfordDictionares api的JSON响应? 我是这样做的,但是我在对象上收到的数据是空的 这是我的JSONWord类 public class JSONWord : Connection { [JsonProperty("id")] public string Word { get; set; } /// <summary> /// </summary> [JsonProperty("etymolo

如何解析来自OxfordDictionares api的JSON响应? 我是这样做的,但是我在对象上收到的数据是空的

这是我的JSONWord类

public class JSONWord : Connection
{

    [JsonProperty("id")]
    public string Word { get; set; }

    /// <summary>

    /// </summary>
    [JsonProperty("etymologies")]
    public string Etymology { get; set; }

    /// <summary>

    /// </summary>
    [JsonProperty("examples")]
    public string Usage { get; set; }

    [JsonProperty("definitions")]
    public string Defenitions { get; set; } //Todo.

 }

您的模型类与json结构不匹配,请尝试使用此模型类(使用生成)


您应该共享responsedata中的json字符串,这样每个人都可以轻松共享responsedata如何使用类名?我看到所有这些都是分部类,那么如何使用主类来创建对象呢?
partial
part不是必需的,您可以删除分部关键字并删除不需要的属性或类,只保留所需的字段,但不更改结构/位置。。这会有用的。非常感谢,所以如果我删除关键字partial,里面会有很多类,对吗?那么我能把所有的都变成一个班级吗?
     HttpWebRequest req = null;
    string PrimeUrl = "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/";
    string uri = PrimeUrl + "robot";
    req = (HttpWebRequest)HttpWebRequest.Create(uri);
    //These are not network credentials, just custom headers
    req.Headers.Add("app_id", "72536848");
    req.Headers.Add("app_key", "0b4ed44eefafe108f88341a4e5cc42ec");
    req.Method = WebRequestMethods.Http.Get;
    req.Accept = "application/json";
    WebResponse response = req.GetResponse();
    StreamReader streamReader = new StreamReader(response.GetResponseStream());
    String responseData = streamReader.ReadToEnd();   
    JSONWord jsonw = JsonConvert.DeserializeObject<JSONWord>(responseData);
{
    "metadata": {
        "provider": "Oxford University Press"
    },
    "results": [
        {
            "id": "robot",
            "language": "en",
            "lexicalEntries": [
                {
                    "entries": [
                        {
                            "etymologies": [
                                "1920s: from Czech, from robota ‘forced labour’. The term was coined in K. Čapek's play R.U.R ‘Rossum's Universal Robots’ (1920)"
                            ],
                            "grammaticalFeatures": [
                                {
                                    "text": "Singular",
                                    "type": "Number"
                                }
                            ],
                            "homographNumber": "000",
                            "senses": [
                                {
                                    "definitions": [
                                        "(especially in science fiction) a machine resembling a human being and able to replicate certain human movements and functions automatically"
                                    ],
                                    "examples": [
                                        {
                                            "text": "a sci-fi movie about time-travelling killer robots"
                                        },
                                        {
                                            "text": "the robot closed the door behind us"
                                        }
                                    ],
                                    "id": "m_en_gbus0877780.011",
                                    "subsenses": [
                                        {
                                            "definitions": [
                                                "a machine capable of carrying out a complex series of actions automatically, especially one programmable by a computer"
                                            ],
                                            "domains": [
                                                "Electronics"
                                            ],
                                            "examples": [
                                                {
                                                    "text": "a robot arm"
                                                },
                                                {
                                                    "text": "half of all American robots are making cars or trucks"
                                                }
                                            ],
                                            "id": "m_en_gbus0877780.008"
                                        },
                                        {
                                            "definitions": [
                                                "a person who behaves in a mechanical or unemotional manner"
                                            ],
                                            "examples": [
                                                {
                                                    "text": "public servants are not expected to be mindless robots"
                                                }
                                            ],
                                            "id": "m_en_gbus0877780.012"
                                        }
                                    ]
                                },
                                {
                                    "crossReferenceMarkers": [
                                        "another term for crawler"
                                    ],
                                    "crossReferences": [
                                        {
                                            "id": "crawler",
                                            "text": "crawler",
                                            "type": "another term for"
                                        }
                                    ],
                                    "domains": [
                                        "Computing"
                                    ],
                                    "id": "m_en_gbus0877780.014"
                                },
                                {
                                    "definitions": [
                                        "a set of automatic traffic lights"
                                    ],
                                    "domains": [
                                        "Motoring"
                                    ],
                                    "examples": [
                                        {
                                            "text": "waiting at a robot I caught the eye of a young woman"
                                        }
                                    ],
                                    "id": "m_en_gbus0877780.016",
                                    "regions": [
                                        "South African"
                                    ]
                                }
                            ]
                        }
                    ],
                    "language": "en",
                    "lexicalCategory": "Noun",
                    "pronunciations": [
                        {
                            "audioFile": "http://audio.oxforddictionaries.com/en/mp3/robot_gb_1.mp3",
                            "dialects": [
                                "British English"
                            ],
                            "phoneticNotation": "IPA",
                            "phoneticSpelling": "ˈrəʊbɒt"
                        }
                    ],
                    "text": "robot"
                }
            ],
            "type": "headword",
            "word": "robot"
        }
    ]
}
public partial class JSONWord
{
    [JsonProperty("metadata")]
    public Metadata Metadata { get; set; }

    [JsonProperty("results")]
    public Result[] Results { get; set; }
}

public partial class Metadata
{
    [JsonProperty("provider")]
    public string Provider { get; set; }
}

public partial class Result
{
    [JsonProperty("id")]
    public string Id { get; set; }

    [JsonProperty("language")]
    public string Language { get; set; }

    [JsonProperty("lexicalEntries")]
    public LexicalEntry[] LexicalEntries { get; set; }

    [JsonProperty("type")]
    public string Type { get; set; }

    [JsonProperty("word")]
    public string Word { get; set; }
}

public partial class LexicalEntry
{
    [JsonProperty("entries")]
    public Entry[] Entries { get; set; }

    [JsonProperty("language")]
    public string Language { get; set; }

    [JsonProperty("lexicalCategory")]
    public string LexicalCategory { get; set; }

    [JsonProperty("pronunciations")]
    public Pronunciation[] Pronunciations { get; set; }

    [JsonProperty("text")]
    public string Text { get; set; }
}

public partial class Entry
{
    [JsonProperty("etymologies")]
    public string[] Etymologies { get; set; }

    [JsonProperty("grammaticalFeatures")]
    public GrammaticalFeature[] GrammaticalFeatures { get; set; }

    [JsonProperty("homographNumber")]
    public string HomographNumber { get; set; }

    [JsonProperty("senses")]
    public Sense[] Senses { get; set; }
}

public partial class GrammaticalFeature
{
    [JsonProperty("text")]
    public string Text { get; set; }

    [JsonProperty("type")]
    public string Type { get; set; }
}

public partial class Sense
{
    [JsonProperty("definitions")]
    public string[] Definitions { get; set; }

    [JsonProperty("examples")]
    public Example[] Examples { get; set; }

    [JsonProperty("id")]
    public string Id { get; set; }

    [JsonProperty("subsenses")]
    public Subsense[] Subsenses { get; set; }

    [JsonProperty("crossReferenceMarkers")]
    public string[] CrossReferenceMarkers { get; set; }

    [JsonProperty("crossReferences")]
    public CrossReference[] CrossReferences { get; set; }

    [JsonProperty("domains")]
    public string[] Domains { get; set; }

    [JsonProperty("regions")]
    public string[] Regions { get; set; }
}

public partial class CrossReference
{
    [JsonProperty("id")]
    public string Id { get; set; }

    [JsonProperty("text")]
    public string Text { get; set; }

    [JsonProperty("type")]
    public string Type { get; set; }
}

public partial class Example
{
    [JsonProperty("text")]
    public string Text { get; set; }
}

public partial class Subsense
{
    [JsonProperty("definitions")]
    public string[] Definitions { get; set; }

    [JsonProperty("domains")]
    public string[] Domains { get; set; }

    [JsonProperty("examples")]
    public Example[] Examples { get; set; }

    [JsonProperty("id")]
    public string Id { get; set; }
}

public partial class Pronunciation
{
    [JsonProperty("audioFile")]
    public string AudioFile { get; set; }

    [JsonProperty("dialects")]
    public string[] Dialects { get; set; }

    [JsonProperty("phoneticNotation")]
    public string PhoneticNotation { get; set; }

    [JsonProperty("phoneticSpelling")]
    public string PhoneticSpelling { get; set; }
}