zoukankan      html  css  js  c++  java
  • 生成json格式数据

             <summary>
             生成json数据
             </summary>
             <param name="query"></param>
             <returns></returns>
            private string BuildJsonForOrganization(IQueryable<Organization> query)
            {
                StringBuilder Json = new StringBuilder();
                if (query.Count() > 0)
                {
                    Json.Append("[");
                    int index = 0;
                    foreach (Organization org in query)
                    {
                        Json.Append("{");
                        Json.Append("id:" + org.Id + ",");
                        Json.Append("pid:" + org.ParentId + ",");
                        Json.Append("name:\"" + org.OrgName + "\",");
                        Json.Append("smalltype:\"" + org.OrgSmallType + "\",");
                        Json.Append("code:\"" + org.Code + "\"");
                        if (org.ParentId == 0)
                        {
                            Json.Append(",expanded:true");
                        }
                        if (index < query.Count() - 1)
                        {
                            Json.Append("},");
                        }
                        else
                        {
                            Json.Append("}");
                        }
                        index++;
                    }
                    return Json.ToString() + "]";
                }
                return Json.ToString();
            }

  • 相关阅读:
    Learning to Compare: Relation Network for Few-Shot Learning 论文笔记
    修改python import模块中的变量
    roslaunch保存的log文件没有打印的ERROR信息
    python json demo
    vscode 1.32.x按下鼠标左键无法拖曳选择,而旧一点的版本1.30.2可以
    java-ee--------jdbc
    集合
    关键字
    java面向对象
    数组
  • 原文地址:https://www.cnblogs.com/chenjt/p/3044733.html
Copyright © 2011-2022 走看看