This table contains a JSON string, not an array. To get the field's contents one would have to deserialize it using JSON.NET and read its contents, eg :
var contactValue=(string)table.Rows[0]["Contacts"];
var contacts=JsonConvert.DeserializeObject<dynamic>(contactValue);
Console.WriteLine("{0}",contacts[0].name);
JsonConvert.DeserializeObject can deserialize a JSON string into a concrete type or a dynamic object. In this example the contents are deserialized into a dynamic object that contains an array. contacts[0].name will return the name attribute of the first element.
It's better to create a concrete type instead of using dynamic in this case:
class Contact
{
public int id {get;set;}
public string name{get;set;}
}
This allows the use of LINQ to retrieve specific attributes, eg :
var contacts=JsonConvert.DeserializeObject<Contact[]>(contactValue);
//Iterate over the results
foreach(var contact in contacts)
{
Console.WriteLine(contact.name);
}
//Or use LINQ
var names=contacts.Select(it=>it.name).ToList();
Using JSONPath
Another option could be to use JSONPath to extract specific values without parsing the entire string.
Instead of deserializing the string, it's parsed with JArray.Parse or JObject.Parse. After that, SelectTokens is used to retrieve the values that match a query path:
var array=JArray.Parse(contactValue);
var tokens=array.SelectTokens("$..name");
foreach(var token in tokens)
{
Console.WriteLine(token);
}
//Concatenate all names into a string
string allNames=String.Join(",",tokens);
$..name means
For any element, return any attribute named name no matter where it is in the hierarchy (..)
Contactscontains a JSON string. Use JSON.NET or another JSON serializer to read the contents.namevalue