public static string ObjectToJson<T>(IList<T> IL, params string[] args)
{
var Json = new StringBuilder();
Json.Append("[");
if (IL.Count > )
{
for (int i = ; i < IL.Count; i++)
{
Type type = IL[i].GetType(); Json.Append("{");
for (int x = ; x < args.Length; x++)
{
var propertyInfo = type.GetProperty(args[x]);
Json.Append("\"" + propertyInfo.Name + "\":\"" + propertyInfo.GetValue(IL[i], null) + "\""); if (x < args.Length - )
{
Json.Append(",");
}
} Json.Append("}");
if (i < IL.Count - )
{
Json.Append(",");
}
}
}
Json.Append("]");
return Json.ToString();
}