RestSharp Deserialization with JSON Array

后端 未结 5 1164
北海茫月
北海茫月 2021-01-01 15:27

I have a JSON response that I\'m trying to deserialize with RestSharp, and it looks like this:

{\"devices\":[{\"device\":{\"id\":7,\"deviceid\":\"abc123\",\"         


        
5条回答
  •  悲&欢浪女
    2021-01-01 15:52

    Something that I ran into is, it does not work if your using interfaces like: IEnumerable or IList, it has to be a concrete type.

    This will not work, where as it does for some other json serializers like json.net.

    public class DevicesList
    {
        public IEnumerable Devices { get; set; }
    }
    
    public class DeviceContainer
    {
       ...
    }
    

    it would have to be something like this:

    public class DevicesList
    {
        public List Devices { get; set; }
    }
    
    public class DeviceContainer
    {
       ...
    }
    

提交回复
热议问题