Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string url = "https://api.dictionaryapi.dev/api/v2/entries/en/impending";
            //string url = "https://api.dictionaryapi.dev/api/v2/entries/en/hello";
            string temp     = HttpCommon.HttpGet(url);
            string response = temp;//.Substring(1, temp.Length - 2);

            /*string googleSearchText = @"
             * {""word"":""hello"",""phonetic"":""həˈləʊ"",""phonetics"":[{""text"":""həˈləʊ"",""audio"":""//ssl.gstatic.com/dictionary/static/sounds/20200429/hello--_gb_1.mp3""},{""text"":""hɛˈləʊ""}],""origin"":""early 19th century: variant of earlier hollo ; related to holla."",""meanings"":[{""partOfSpeech"":""exclamation"",""definitions"":[{""definition"":""used as a greeting or to begin a phone conversation."",""example"":""hello there, Katie!"",""synonyms"":[],""antonyms"":[]}]},{""partOfSpeech"":""noun"",""definitions"":[{""definition"":""an utterance of ‘hello’; a greeting."",""example"":""she was getting polite nods and hellos from people"",""synonyms"":[],""antonyms"":[]}]},{""partOfSpeech"":""verb"",""definitions"":[{""definition"":""say or shout ‘hello’."",""example"":""I pressed the phone button and helloed"",""synonyms"":[],""antonyms"":[]}]}]}
             * ";
             * string response = @"
             * {""word"":""impending"",""phonetic"":""ɪmˈpɛndɪŋ"",""phonetics"":[{""text"":""ɪmˈpɛndɪŋ"",""audio"":""//ssl.gstatic.com/dictionary/static/sounds/20200429/impending--_gb_1.mp3""}],""meanings"":[{""partOfSpeech"":""adjective"",""definitions"":[{""definition"":""(of an event regarded as threatening or significant) about to happen; forthcoming."",""example"":""the author had returned to his country ahead of the impending war"",""synonyms"":[],""antonyms"":[]}]}]},{""word"":""impend"",""phonetic"":""ɪmˈpɛnd"",""phonetics"":[{""text"":""ɪmˈpɛnd"",""audio"":""//ssl.gstatic.com/dictionary/static/sounds/20200429/impend--_gb_1.mp3""}],""origin"":""late 16th century: from Latin impendere, from in- ‘towards, upon’ + pendere ‘hang’."",""meanings"":[{""partOfSpeech"":""verb"",""definitions"":[{""definition"":""(of an event regarded as threatening or significant) be about to happen."",""example"":""it seemed certain that some great trial of strength impended between the opponents"",""synonyms"":[""imminent"",""at hand"",""close"",""close at hand"",""near"",""nearing"",""approaching"",""coming"",""forthcoming"",""upcoming"",""to come"",""on the way"",""about to happen"",""upon us"",""in store"",""in the offing"",""in the pipeline"",""on the horizon"",""in the air"",""in the wind"",""brewing"",""looming"",""looming large"",""threatening"",""menacing"",""on the cards""],""antonyms"":[]}]}]}
             * ";*/

            try
            {
                List <api.dictionaryapi.dev.Root> myRoot  = JsonConvert.DeserializeObject <List <api.dictionaryapi.dev.Root> >(response);
                api.dictionaryapi.dev.Root        oneRoot = myRoot[0];

                MessageBox.Show(oneRoot.word);
                foreach (Meaning m in oneRoot.meanings)
                {
                    MessageBox.Show(m.partOfSpeech + ":" + m.definitions[0].definition);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //           MessageBox.Show(myRoot.meanings[0].partOfSpeech + ":" + myRoot.meanings[0].definitions[0].definition);
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string url      = "https://dictionaryapi.com/api/v3/references/learners/json/hello?key=f8c7ea01-c305-41d2-8d80-5d6551d604f3";
            string temp     = HttpCommon.HttpGet(url);
            string response = temp;//.Substring(1, temp.Length - 2);

            try
            {
                List <dictionaryapi.com.Root> myRoot    = JsonConvert.DeserializeObject <List <dictionaryapi.com.Root> >(response);
                dictionaryapi.com.Root        firstRoot = myRoot[0];
                MessageBox.Show(firstRoot.meta.id);

/*                foreach (Meaning m in myRoot.meanings)
 *              {
 *                  MessageBox.Show(m.partOfSpeech + ":" + m.definitions[0].definition);
 *              }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //           MessageBox.Show(myRoot.meanings[0].partOfSpeech + ":" + myRoot.meanings[0].definitions[0].definition);
        }