I am trying to deserialize a json object that contains a list of countries but I Keep getting an error that reads
Type System.String' is not supported for deserialization of an array.
I am able to retrieve the JSON object(List of Countries) from the API but when I try to deserialize the JSON object
This is my method to get the list of countries and tie them to a countriesList model
public List<CountriesList> GetCountries()
{
try
{
string apiCountriesUrl = "https://restcountries.eu/rest/v2/all";
string response = GetServiceCallByUrl(apiCountriesUrl);
var countriesObj = System.Web.Helpers.Json.Decode<List<CountriesList>>(response);
return countriesObj;
}
catch (Exception exception)
{
throw exception;
}
}
My CountriesList Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ApplicationPortal.Models
{
public class CountriesList
{
public string name { get; set; }
public string callingCodes { get; set; }
}
}