Sorry for basic question, I'm beginner and tried to find my problem, but wasn't able to
string json = "{\"EmailList\":[{\"name\":\"John Bravo\",\"email\":\"email@gmail.com\"},{\"name\":\"Daniel Alutcher\",\"email\":\"email@gmail.com\"},{\"name\":\"James Rodriguez\",\"email\":\"email@gmail.com\"}]}";
JObject rss = JObject.Parse(json);
var data = JsonConvert.DeserializeObject<dynamic>(json);
dynamic emails = data.EmailList;
List<string> emailList = new List<string>();
foreach (dynamic item in emails)
{
int x = 0;
if (item.email != null)
{
Console.WriteLine(item.email);
//emailList.Add(item.email); // throws exception System.Collections.Generic.List<string>.Add(string)' has some invalid arguments'
}
}
So I'm looping trough this JSON and I'm able to get in console each email, but when I'm trying to add it to a list, it's throwing exception error