Я создаю приложение xamarin, которое помещает запрос в api rest. Я следовал учебным пособиям, и все, кажется, в порядке, но когда я добираюсь до JsonConvert.DeserializeObjects, он выдает ошибку.
Мой главный вопрос: правильно ли настроены мои классы и мои http-запросы?
Вот мои уроки для json, сделанные из json2csharp
public class Results
{
public int skip { get; set; }
public int limit { get; set; }
public int total { get; set; }
}
public class Meta
{
public string disclaimer { get; set; }
public string terms { get; set; }
public string license { get; set; }
public string last_updated { get; set; }
public Results results { get; set; }
}
public class Openfda
{
public List<string> product_ndc { get; set; }
public List<bool> is_original_packager { get; set; }
public List<string> package_ndc { get; set; }
public List<string> generic_name { get; set; }
public List<string> spl_set_id { get; set; }
public List<string> brand_name { get; set; }
public List<string> manufacturer_name { get; set; }
public List<string> unii { get; set; }
public List<string> rxcui { get; set; }
public List<string> spl_id { get; set; }
public List<string> substance_name { get; set; }
public List<string> product_type { get; set; }
public List<string> route { get; set; }
public List<string> application_number { get; set; }
}
public class Result
{
public string effective_time { get; set; }
public List<string> spl_unclassified_section_table { get; set; }
public List<string> contraindications { get; set; }
public List<string> precautions { get; set; }
public List<string> warnings { get; set; }
public List<string> description { get; set; }
public List<string> spl_product_data_elements { get; set; }
public Openfda openfda { get; set; }
public string version { get; set; }
public List<string> dosage_and_administration { get; set; }
public List<string> adverse_reactions { get; set; }
public List<string> spl_unclassified_section { get; set; }
public List<string> how_supplied_table { get; set; }
public List<string> how_supplied { get; set; }
public List<string> package_label_principal_display_panel { get; set; }
public List<string> indications_and_usage { get; set; }
public List<string> clinical_pharmacology { get; set; }
public string set_id { get; set; }
//public string id { get; set; }
public List<string> overdosage { get; set; }
}
public class RootObject
{
public Meta meta { get; set; }
public List<Result> results { get; set; }
}
и вот мой код для создания вызова к фактическому API
HttpClient client = new HttpClient();
var baseURI = new Uri("https://api.fda.gov/drug/label.json?search=openfda.package_ndc:" + pullText.Text + "&limit=1");
client.BaseAddress = baseURI;
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage resp = client.GetAsync(baseURI).Result;
var dataObjects = resp.Content.ReadAsStringAsync().Result;
var otherView = JsonConvert.DeserializeObject<Openfda>("{\"results\":[\"openfda\":{\"product_ndc\":");