I'm getting this json from an API.
string json = "{'serviceSession':{ '123123123':[{'apn':'abc'},{'apn':'bcd'},{'apn':'def'}]}}"; When I'm trying to deserialize it with
public class ServiceSession { public Dictionary<string, List<ServiceSessionType>> ServiceSessions { get; set; } } public class ServiceSessionType { public string Apn { get; set; } } and
var test = JsonConvert.DeserializeObject<ServiceSession> (json); I'm getting null.
What's wrong? any ideas?
Thank you in advance!!
123123123is an array of objects, not a dictionary. Even if it were a dictionary (which it most definately is not) it would still blow up because you would have duplicate keys.ServiceSessionsis not the same asserviceSession123123123is the key in the dictionary :)