public static string ModelToJsonData <T>(T model) { StringBuilder jsonSB = new StringBuilder(); jsonSB.Append("{"); Type t = typeof(T); PropertyInfo[] propertyArr = t.GetProperties(); int index = 0; foreach (PropertyInfo PInfo in propertyArr) { if (index > 0) { jsonSB.Append(","); } jsonSB.Append("\"" + PInfo.Name + "\":\"" + PInfo.GetValue(model, null).ToString().Replace((char)13, ' ').Replace((char)10, ' ').Replace("\n\r", " ") + "\""); index++; } jsonSB.Append("}"); return(jsonSB.ToString()); }