public static T ToModel <T>(string json, JsonOptions options) { try { return(JavaScriptObjectNotation.JsonToModel <T>(json, options)); } catch (Exception ex) { throw new FormatDeserializeException(Constants.Format.DESERIALIZE_ERROR_MESSAGE, ex, FormatRange.Json, typeof(T), json); } }
public Response <T> ToModel <T>(string json, JsonOptions options) { var response = new Response <T>(); try { var model = JavaScriptObjectNotation.JsonToModel <T>(json, options); response = response.With(model); } catch (Exception ex) { ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}"); } return(response); }
public Maybe <T, FormatDeserializeException> ToModel <T>(string json, JsonOptions options) { var maybe = new Maybe <T, FormatDeserializeException>(); try { var model = JavaScriptObjectNotation.JsonToModel <T>(json, options); maybe = maybe.With(model); } catch (Exception ex) { ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}"); maybe = maybe.With(new FormatDeserializeException(Constants.Format.DESERIALIZE_ERROR_MESSAGE, ex, FormatRange.Json, typeof(T), json)); } return(maybe); }