RestSharp client returns all properties as null when deserializing JSON response

别说谁变了你拦得住时间么 提交于 2019-11-30 08:46:17

What is the Content-Type in the response? If not a standard content type like "application/json", etc. then RestSharp won't understand which deserializer to use. If it is in fact a content type not "understood" by RestSharp (you can verify by inspecting the Accept sent in the request), then you can solve this by doing:

client.AddHandler("my_custom_type", new JsonDeserializer());

EDIT:

Ok, sorry, looking at the JSON again, you need something like:

public class LocationResponse
   public LocationResult Result { get; set; }
}

public class LocationResult {
  public Location Location { get; set; }
}

And then do:

client.Execute<LocationResponse>(request);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!