I'm new here, so please excuse any omissions in the correct question procedure!
Basically, I'm trying to deserialize a json array from the Pearson Dictionary Web API. Here's the JSON (I removed some redundant indexes resultsto save space):
{
"status": 200,
"offset": 0,
"limit": 10,
"count": 10,
"total": 47,
"url": "/v2/dictionaries/ldoce5/entries?headword=test",
"results": [
{
"datasets": [
"ldoce5",
"dictionary"
],
"headword": "test",
"homnum": 1,
"id": "cqAFzDfHTM",
"part_of_speech": "noun",
"pronunciations": [
{
"audio": [
{
"lang": "British English",
"type": "pronunciation",
"url": "/v2/dictionaries/assets/ldoce/gb_pron/brelasdetest.mp3"
},
{
"lang": "American English",
"type": "pronunciation",
"url": "/v2/dictionaries/assets/ldoce/us_pron/test1.mp3"
}
],
"ipa": "test"
}
],
"senses": [
{
"definition": [
"a set of questions, exercises, or practical activities to measure someone skill, ability, or knowledge"
],
"examples": [
{
"audio": [
{
"type": "example",
"url": "/v2/dictionaries/assets/ldoce/exa_pron/p008-001626298.mp3"
}
],
"text": "Did you get a good mark in the test ?"
}
],
"gramatical_examples": [
{
"examples": [
{
"audio": [
{
"type": "example",
"url": "/v2/dictionaries/assets/ldoce/exa_pron/p008-000592041.mp3"
}
],
"text": "We have a test on irregular verbs tomorrow."
}
],
"pattern": "test on"
}
],
"signpost": "exam"
}
],
"url": "/v2/dictionaries/entries/cqAFzDfHTM"
}
]
}
And here is the C # code that I use to deserialize the above:
class Program
{
static void Main(string[] args)
{
string word = "test";
string sURL = "https://api.pearson.com:443/v2/dictionaries/ldoce5/entries?headword=" + word;
WebClient client = new WebClient();
string full = client.DownloadString(sURL);
var final = JsonConvert.DeserializeObject<Dictionary>(full);
Console.WriteLine(final.results[0].senses.definition);
}
}
public class Dictionary
{
public Result[] results { get; set; }
}
public class Result
{
public string part_of_speech { get; set; }
public Senses senses { get; set; }
}
public class Senses
{
public string definition { get; set; }
}
For some reason, I get this strange error when I try to run it:
JSON (, [1,2,3]) 'TestingJson.Senses', JSON (, { "name": "value" }) . , JSON JSON (, { "name": "value" }) , (, ICollection, IList), List, JSON. JsonArrayAttribute , JSON. 'results [0].senses', 1, 512.
!