Here's the JSON response that I got from web service:
{
"odata.metadata": "https://graph.windows.net/00c6cd14-eaee-4d02-9807-59bcd4f98847/$metadata#domainDnsRecords",
"value": [{
"odata.type": "Microsoft.DirectoryServices.DomainDnsTxtRecord",
"dnsRecordId": "aceff52c-06a5-447f-ac5f-256ad243cc5c",
"isOptional": false,
"label": "aro3652698.applabdnstest1.com",
"recordType": "Txt",
"supportedService": "Email",
"ttl": 3600,
"text": "MS=ms14815229"
},
{
"odata.type": "Microsoft.DirectoryServices.DomainDnsMxRecord",
"dnsRecordId": "5fbde38c-0865-497f-82b1-126f596bcee9",
"isOptional": false,
"label": "aro3652698.applabdnstest1.com",
"recordType": "Mx",
"supportedService": "Email",
"ttl": 3600,
"mailExchange": "ms14815229.msv1.invalid",
"preference": 32767
}]
}
Elements in the array under "value" token are of different derived type.
There's DomainDnsRecord abstract base class, and classes that inherit from base are DomainDnsTxtRecord and DomainDnsMxRecord.
In the given JSON array (but not always!), first element is of DomainDnsTxtRecord and the second one is of DomainDnsMxRecord type.
The field that contains information about what type the given element is, is: "recordType".
What is the easiest, most convenient way to deserialize this JSON array into a list of base classes, e.g. List<DomainDnsRecord> (using Newtonsoft for example)?