public static string ObjectToJson<T>(IList<T> IL, params string[] args) { var Json = new StringBuilder(); Json.Append("["); if (IL.Count > 0) { for (int i = 0; i < IL.Count; i++) { Type type = IL[i].GetType(); Json.Append("{"); for (int x = 0; x < args.Length; x++) { var PRopertyInfo = type.GetProperty(args[x]); Json.Append("/"" + propertyInfo.Name + "/":/"" + propertyInfo.GetValue(IL[i], null) + "/""); if (x < args.Length - 1) { Json.Append(","); } } Json.Append("}"); if (i < IL.Count - 1) { Json.Append(","); } } } Json.Append("]"); return Json.ToString(); }
新闻热点
疑难解答