using Serilog; using ShareeBike.Repository.Exception; namespace ShareeBike.Repository.Response { public static class JsonConvertRethrow { /// /// Deserializes COPRI responses in a consitent way for entire app. /// /// Type of object to serialize to. /// JSON to deserialize. /// Deserialized object. public static T DeserializeObject(string response) { try { return Newtonsoft.Json.JsonConvert.DeserializeObject(response); } catch (System.Exception ex) { Log.Error("Deserializing response failed. {@Exception}",ex); throw new DeserializationException(ex); } } public static string SerializeObject(object value) => Newtonsoft.Json.JsonConvert.SerializeObject(value); } }