Deserializing a json string with newtonsoft or restsharp

I also have this problem, and I solved it using the Newtonsoft.Json.

Include the following namespaces:

using Newtonsoft.Json;
using RestSharp;

and try something like this:

return JsonConvert.DeserializeObject<T>(response.Content);

On the response.Content, you will have the raw result, so just deserialize this string to a json object. The T in the case is the type you need to deserialize.

For example:

var customerDto = JsonConvert.DeserializeObject<CustomerDto>(response.Content);

If you want to avoid using extra libraries, try this:

RestSharp.RestResponse response = new RestSharp.RestResponse();

response.Content = myStringFromDB; 

RestSharp.Deserializers.JsonDeserializer deserial = new JsonDeserializer();

Customer x = deserial.Deserialize<Customer>(response);

Caveats apply - not extensively tested - but seems to work well enough.