public static string FromModel <T>(T model, JsonOptions options)
 {
     try
     {
         return(JavaScriptObjectNotation.ModelToJson <T>(model, options));
     }
     catch (Exception ex)
     {
         throw new FormatSerializeException(Constants.Format.SERIALIZE_ERROR_MESSAGE, ex, FormatRange.Json, model);
     }
 }
 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 <string> FromModel <T>(T model, JsonOptions options)
        {
            var response = new Response <string>();

            try
            {
                var json = JavaScriptObjectNotation.ModelToJson <T>(model, options);
                response = response.With(json);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error deserializing format to type {typeof(T).FullName}: {ex}");
            }

            return(response);
        }
        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 <string, FormatSerializeException> FromModel <T>(T model, JsonOptions options)
        {
            var maybe = new Maybe <string, FormatSerializeException>();

            try
            {
                var json = JavaScriptObjectNotation.ModelToJson <T>(model, options);
                maybe = maybe.With(json);
            }
            catch (Exception ex)
            {
                ex.LogValue($"Error serializing format to type {typeof(T).FullName}: {ex}");
                maybe = maybe.With(new FormatSerializeException(Constants.Format.SERIALIZE_ERROR_MESSAGE, ex, FormatRange.Json, model));
            }

            return(maybe);
        }
        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);
        }
 public static string ModelToJson <T>(T model, JsonOptions options)
 {
     return(JsonSerializer.Serialize <T>(model, options.SerializerSettings));
 }
 public static T JsonToModel <T>(string json, JsonOptions options)
 {
     return(JsonSerializer.Deserialize <T>(string.IsNullOrEmpty(json) ? "null" : json, options.SerializerSettings));
 }