Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json;
- using System.Collections.Generic;
- public static string FromClass<T>(T data, bool isEmptyToNull = false,
- JsonSerializerSettings jsonSettings = null)
- {
- string response = string.Empty;
- if (!EqualityComparer<T>.Default.Equals(data, default(T)))
- response = JsonConvert.SerializeObject(data, jsonSettings);
- return isEmptyToNull ? (response == "{}" ? "null" : response) : response;
- }
Add Comment
Please, Sign In to add comment