When having the following code
var TermSource =
token.Value<JArray>("annotations")
.Values<string>("Term Source")
.FirstOrDefault();
I am able to get results for the following JSON block
"annotations": [
{
"Preferred Term": "Text1"
},
{
"Term Source": "Text2"
}
],
However, when running the following line
var country_code_iso3166_alpha2 =
token.Value<JArray>("datatype_properties")
.Values<string>("country_code_iso3166_alpha2")
.FirstOrDefault();
for the following JSON block
"datatype_properties": {
"country_name_iso3166_short": [
"Text Text"
],
"country_code_iso3166_alpha2": [
"txt1"
],
"country_code_iso3166_alpha3": [
"txt2"
],
"country_code_un_numeric3": [
"10"
]
I get the following error
'Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken'
How I should fix the LINQ statement to retrieve the value for the 'country_code_iso3166_alpha2' data