mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-27 23:06:29 +02:00
Initial version.
This commit is contained in:
parent
193aaa1a56
commit
b72c67a53e
228 changed files with 25924 additions and 0 deletions
27
TINKLib/Repository/Response/JsonConvert.cs
Normal file
27
TINKLib/Repository/Response/JsonConvert.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using TINK.Repository.Exception;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
public static class JsonConvert
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes COPRI responses in a consitent way for entire app.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of object to serialize to.</typeparam>
|
||||
/// <param name="response">JSON to deserialize.</param>
|
||||
/// <returns>Deserialized object.</returns>
|
||||
public static T DeserializeObject<T>(string response)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(response);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new DeserializationException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static string SerializeObject(object value) => Newtonsoft.Json.JsonConvert.SerializeObject(value);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue