C# 转json

  #region MyRegion


                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    foreach (System.Reflection.PropertyInfo p in model.GetType().GetProperties())
                    {
                        var ss = p.Name; //属性名称
                        if (ss == "Role" || ss == "Department" || ss == "ApplySolver")
                        {
                            continue;
                        }
                        var s1 = p.GetValue(model);//属性值
                        sb.AppendFormat("\"{0}\":\"{1}\"", ss, s1);
                        sb.Append(",");
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append("}");
                    desc = sb.ToString();
                    sb.Length = 0;

                    #endregion

 

posted @ 2019-10-31 14:38  enych  阅读(339)  评论(0编辑  收藏  举报